-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenstat.py
executable file
·316 lines (270 loc) · 8.08 KB
/
genstat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
#!/usr/bin/python
# Gentoo emerge status
# This script requires genlop,
# you can install it using `emerge genlop`.
# Copyleft (c) 2005 - Milot Shala <[email protected]>
# http://forums.gentoo.org/viewtopic-p-2970419-highlight-.html#2970419
import sys
import os
import time
#colors
color={}
color["r"]="\x1b[31;01m"
color["g"]="\x1b[32;01m"
color["b"]="\x1b[34;01m"
color["0"]="\x1b[0m"
def r(txt):
return color["r"]+txt+color["0"]
def g(txt):
return color["g"]+txt+color["0"]
def b(txt):
return color["b"]+txt+color["0"]
# View Options
def view_opt():
print
print
print g("full-info - View full information for emerged package")
print g("cur - View current emerge")
print g("hist - View history of emerged packages by day")
print g("hist-all - View full list of history of emerged packages")
print g("rsync - View rsync history")
print g("time - View time for compiling a package")
print g("time-unmerged - View time of unmerged packages")
print
command = raw_input(r("Press Enter to return to main "))
if command == '':
c()
program()
else:
c()
program()
# system command 'clear'
def c():
os.system('clear')
# Base program
def program():
c()
print g("Gentoo emerge status script")
print ("---------------------------")
print
print ("1]") + g(" Enter options")
print ("2]") + g(" View options")
print ("3]") + g(" Exit")
print
command = input("[]> ")
if command == 1:
print
print r("""First of all you must view options to know what to use, you can enter option name ( if you know any ) or type `view-opt` to view options.""")
print
time.sleep(2)
command = raw_input(b("Option name: "))
if (command == 'view-opt' or command == 'VIEW-OPT'):
view_opt()
elif command == 'full-info':
c()
print g("Full information for a single package")
print ("-------------------------------------")
print
print b("Enter package name")
command=raw_input("> ")
c()
print g("Full information for package"), b(command)
print ("-----------------------------------")
print
pack=['genlop -i '+command]
pack_=" ".join(pack)
os.system(pack_)
print
print r("Press Enter to return to main.")
command=raw_input()
if command == '':
c()
program()
else:
c()
program()
elif command == 'cur':
if command == 'cur':
c()
print g("Current emerge session(s)")
print ("-------------------------")
print
print b("Listing current emerge session(s)")
print
time.sleep(1)
os.system('genlop -c')
print
print r("Press Enter to return to main.")
command = raw_input()
if (command == ''):
c()
program()
else:
c()
program()
elif command == 'hist':
if command == 'hist':
c()
print g("History of merged packages")
print ("---------------------------")
print
time.sleep(1)
print b("Enter number of how many days ago you want to see the packages")
command = raw_input("> ")
c()
print g("Packages merged "+b(command)+ g(" day(s) before"))
print ("------------------------------------")
pkg=['genlop --list --date '+command+' days ago']
pkg_=" ".join(pkg)
os.system(pkg_)
print
print r("Press Enter to return to main.")
command = raw_input()
if command == '':
c()
program()
else:
c()
program()
elif command == 'hist-all':
c()
print g("Full history of merged individual packages")
print ("--------------------------------------")
print
print b("Do you want to view individual package?")
print r("YES/NO?")
command = raw_input("> ")
print
if (command == 'yes' or command == 'YES'):
print g("Enter package name")
command = raw_input("> ")
print
pkg=['genlop -l | grep '+command+ ' | less']
pkg_=" ".join(pkg)
os.system(pkg_)
print
print r("Press Enter to return to main")
command = raw_input()
if command == '':
c()
program()
else:
c()
program()
elif (command == 'no' or command == 'NO'):
pkg=['genlop -l | less']
pkg_=" ".join(pkg)
os.system(pkg_)
print
print r("Press Enter to return to main")
command = raw_input()
if command == '':
c()
program()
else:
c()
program()
else:
c()
program()
elif command == 'rsync':
print g("RSYNC updates")
print
print
print
print b("You can view rsynced time by year!")
print r("Do you want this script to do it for you? (yes/no)")
command = raw_input("> ")
if (command == 'yes' or command == 'YES'):
print
print g("Enter year i.e"), b("2005")
print
command = raw_input("> ")
rsync=['genlop -r | grep '+command+' | less']
rsync_=" ".join(rsync)
os.system(rsync_)
print
print r("Press Enter to return to main.")
c()
program()
elif (command == 'no' or command == 'NO'):
os.system('genlop -r | less')
print
print r("Press Enter to return to main.")
command = raw_input()
if command == '':
c()
program()
else:
c()
program()
elif command == 'time':
c()
print g("Time of package compilation")
print ("---------------------------")
print
print
print b("Enter package name")
pkg_name = raw_input("> ")
pkg=['emerge '+pkg_name+' -p | genlop -p | less']
pkg_=" ".join(pkg)
os.system(pkg_)
print
print r("Press Enter to return to main")
time.sleep(2)
command = raw_input()
if command == '':
c()
program()
else:
c()
program()
elif command == 'time-unmerged':
c()
print g("Show when package(s) is/when is unmerged")
print ("----------------------------------------")
print
print b("Enter package name: ")
name = raw_input("> ")
pkg=['genlop -u '+name]
pkg_=" ".join(pkg)
os.system(pkg_)
print
print r("Press Enter to return to main")
time.sleep(2)
command = raw_input()
if command == '':
c()
program()
else:
c()
program()
else:
print
print r("Wrong Selection!")
time.sleep(2)
c()
program()
elif command == 2:
view_opt()
command = raw_input(r("Press Enter to return to main "))
if command == '':
c()
program()
else:
c()
program()
elif command == 3:
print
print b("Thank you for using this script")
print
time.sleep(1)
sys.exit()
else:
print
print r("Wrong Selection!")
time.sleep(2)
c()
program()
command = ("")
program()