|
1 | | -#flag=imp |
2 | | - |
3 | | -''' This is the common library developed to satisfy the needs of commandline python applications . |
4 | | - It contains necessary std libraries and basic functions for its users.''' |
5 | | - |
6 | | - |
7 | | -try: |
8 | | - import hashlib |
9 | | - import time |
10 | | - import platform |
11 | | - import os |
12 | | - import getpass |
13 | | - import webbrowser |
14 | | - |
15 | | -except ImportError: |
16 | | - print('Critical Error:Necessary Python Modules are missing!') |
17 | | - print('Commons module couldnot satisfy all the dependencies!') |
18 | | - x=input('\nPress any key to exit...') |
19 | | - exit() |
20 | | - |
21 | | -def r(f): |
22 | | - if os.path.exists(f): |
23 | | - os.remove(f) |
24 | | - |
25 | | -def detect(cmd,web,snam,pkg): |
26 | | - |
27 | | - if platform.system().lower()=='windows': |
28 | | - if os.system(cmd+'>chk')!=0: |
29 | | - os.system('cls') |
30 | | - print('\nError: '+pkg+' is not detected!') |
31 | | - print('\nPlease wait opening '+snam +' website in your browser!\nYou Have to download and install it.\n') |
32 | | - webbrowser.open(web) |
33 | | - x=input('\nPress any key to exit...') |
34 | | - r('chk') |
35 | | - exit() |
36 | | - |
37 | | - else: |
38 | | - if os.system(cmd+'>chk')!=0: |
39 | | - os.system('clear') |
40 | | - print('\nError:'+pkg+' is not detected!\n Please install The package to continue.') |
41 | | - x=input('\nPress any key to exit...') |
42 | | - r('chk') |
43 | | - exit() |
44 | | - r('chk') |
45 | | - |
46 | | - |
47 | | -def start(): |
48 | | - print('\n<-----Task Started----->\n') |
49 | | - |
50 | | -def end(): |
51 | | - print('\n<-----Task Completed----->\n') |
52 | | - |
53 | | -def tsks(): |
54 | | - start() |
55 | | - |
56 | | -def tske(): |
57 | | - end() |
58 | | - |
59 | | -def tskf(): |
60 | | - print('\n<-----Task Failed !----->\n') |
61 | | - |
62 | | - |
63 | | -def wait(): |
64 | | - x=input('\nPress any key to continue...\n') |
65 | | - |
66 | | -def display(file): |
67 | | - with open(file,'r') as f: |
68 | | - s=f.read(1024) |
69 | | - print(s) |
70 | | - while len(s)>0: |
71 | | - s=f.read(1024) |
72 | | - print(s) |
73 | | - |
74 | | - |
75 | | -def gpg(): |
76 | | - detect('gpg --version','https://gpg4win.org','gpg4win','Gnupg') |
77 | | - |
78 | | - |
79 | | -def exiftool(): |
80 | | - detect('exiftool -h','https://exiftool.org','exiftool','Exiftool') |
81 | | - |
82 | | -def ffmpeg(): |
83 | | - detect('ffmpeg --help','https://ffmpeg.org/','ffmpeg','ffmpeg') |
84 | | - |
85 | | - |
86 | | -def copy(file,file1): |
87 | | - if os.path.exists(file): |
88 | | - f=open(file,'r') |
89 | | - s=open(file1,'a+') |
90 | | - if os.path.getsize(file)<(1024*1024*1024): |
91 | | - buff=f.read() |
92 | | - s.write('\n-------------------------------------------------------\n') |
93 | | - s.write(buff) |
94 | | - f.close() |
95 | | - s.close() |
96 | | - |
97 | | -def bcopy(file,file1): |
98 | | - if os.path.exists(file): |
99 | | - f=open(file,'rb') |
100 | | - s=open(file1,'ab+') |
101 | | - if os.path.getsize(file)<(1024*1024*1024): |
102 | | - buff=f.read() |
103 | | - s.write(buff) |
104 | | - f.close() |
105 | | - s.close() |
106 | | - |
107 | | -def cls(): |
108 | | - if platform.system().lower()=='windows': |
109 | | - os.system('cls') |
110 | | - else: |
111 | | - os.system('clear') |
112 | | - |
113 | | - |
114 | | - |
115 | | - |
116 | | - |
117 | | - |
118 | | - |
119 | | - |
120 | | - |
| 1 | +#flag=imp |
| 2 | + |
| 3 | +''' |
| 4 | +This is the common library developed to satisfy the needs of commandline python applications . |
| 5 | +It contains necessary std libraries and basic functions for its users. |
| 6 | +''' |
| 7 | + |
| 8 | +try: |
| 9 | + import hashlib |
| 10 | + import time |
| 11 | + import platform |
| 12 | + import os |
| 13 | + import getpass |
| 14 | + import webbrowser |
| 15 | + |
| 16 | +except ImportError: |
| 17 | + print('Critical Error: Necessary Python Modules are missing!') |
| 18 | + print('Commons module couldnot satisfy all the dependencies!') |
| 19 | + x=input('\nPress any key to exit...') |
| 20 | + exit() |
| 21 | + |
| 22 | +# Deletes file after checking if it exists or not. |
| 23 | +def r(f): |
| 24 | + if os.path.exists(f): |
| 25 | + os.remove(f) |
| 26 | + |
| 27 | +# Function to open website if prerequisite software is not found in PC. |
| 28 | +def detect(cmd,web,snam,pkg): |
| 29 | + |
| 30 | + if platform.system().lower()=='windows': |
| 31 | + if os.system(cmd+'>chk')!=0: |
| 32 | + os.system('cls') |
| 33 | + print('\nError: '+pkg+' is not detected!') |
| 34 | + print('\nPlease wait opening '+snam +' website in your browser!\nYou Have to download and install it.\n') |
| 35 | + webbrowser.open(web) |
| 36 | + x=input('\nPress any key to exit...') |
| 37 | + r('chk') |
| 38 | + exit() |
| 39 | + |
| 40 | + else: |
| 41 | + if os.system(cmd+'>chk')!=0: |
| 42 | + os.system('clear') |
| 43 | + print('\nError:'+pkg+' is not detected!\n Please install The package to continue.') |
| 44 | + x=input('\nPress any key to exit...') |
| 45 | + r('chk') |
| 46 | + exit() |
| 47 | + r('chk') |
| 48 | + |
| 49 | + |
| 50 | +def start(): |
| 51 | + print('\n<-----Task Started----->\n') |
| 52 | + |
| 53 | +def end(): |
| 54 | + print('\n<-----Task Completed----->\n') |
| 55 | + |
| 56 | +def tsks(): |
| 57 | + start() |
| 58 | + |
| 59 | +def tske(): |
| 60 | + end() |
| 61 | + |
| 62 | +def tskf(): |
| 63 | + print('\n<-----Task Failed !----->\n') |
| 64 | + |
| 65 | + |
| 66 | +def wait(): |
| 67 | + x=input('\nPress any key to continue...\n') |
| 68 | + |
| 69 | +# Function to Display contents of text file. |
| 70 | +def display(file): |
| 71 | + with open(file,'r') as f: |
| 72 | + s=f.read(1024) |
| 73 | + print(s) |
| 74 | + while len(s)>0: |
| 75 | + s=f.read(1024) |
| 76 | + print(s) |
| 77 | + |
| 78 | + |
| 79 | +def gpg(): |
| 80 | + detect('gpg --version','https://gpg4win.org','gpg4win','Gnupg') |
| 81 | + |
| 82 | + |
| 83 | +def exiftool(): |
| 84 | + detect('exiftool -h','https://exiftool.org','exiftool','Exiftool') |
| 85 | + |
| 86 | +def ffmpeg(): |
| 87 | + detect('ffmpeg --help','https://ffmpeg.org/','ffmpeg','ffmpeg') |
| 88 | + |
| 89 | +# Function to copy textfile. |
| 90 | +def copy(file,file1): |
| 91 | + if os.path.exists(file): |
| 92 | + f=open(file,'r') |
| 93 | + s=open(file1,'a+') |
| 94 | + if os.path.getsize(file)<(1024*1024*1024): |
| 95 | + buff=f.read() |
| 96 | + s.write('\n-------------------------------------------------------\n') |
| 97 | + s.write(buff) |
| 98 | + f.close() |
| 99 | + s.close() |
| 100 | + |
| 101 | +# Function to copy binaryfile. |
| 102 | +def bcopy(file,file1): |
| 103 | + if os.path.exists(file): |
| 104 | + f=open(file,'rb') |
| 105 | + s=open(file1,'ab+') |
| 106 | + if os.path.getsize(file)<(1024*1024*1024): |
| 107 | + buff=f.read() |
| 108 | + s.write(buff) |
| 109 | + f.close() |
| 110 | + s.close() |
| 111 | + |
| 112 | +# Clearscreen |
| 113 | +def cls(): |
| 114 | + if platform.system().lower()=='windows': |
| 115 | + os.system('cls') |
| 116 | + else: |
| 117 | + os.system('clear') |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | + |
| 122 | + |
| 123 | + |
| 124 | + |
| 125 | + |
| 126 | + |
0 commit comments