TIP Getting total merge time
From Gentoo Linux Wiki
This is a very simple and most likely inefficient way of getting your total merge time, but until genlop can do it on its own, here you go:
[edit] Emerge Genlop
Hopefully you don't need this step but here you are:
emerge gentoolkit
or
emerge app-portage/genlop
[edit] Create genlop-total
#!/usr/bin/env python
import commands,output
genlop = commands.getoutput("genlop -ltn")
genlops = genlop.strip().split("\n")
genlop2 = []
genlop3 = []
ttime = 0
for i in genlops:
if i != '':
if i.strip().startswith("merge time"):
if i.find('log error') != -1:
continue
genlop2.append(i.strip())
for i in genlop2:
i = i.split(":", 1)[1].strip()[:-1]
i2 = i.split(",", 1)
if len(i2) > 1:
hours = i2[0]
i3 = i2[1]
else:
hours = "0"
i3 = i2[0]
i4 = i3.split("and")
if len(i4) > 1:
minutes = i4[0]
seconds = i4[1]
else:
minutes = "0"
seconds = i4[0]
hours = hours.strip().split(" ", 1)[0]
minutes = minutes.strip().split(" ", 1)[0]
seconds = seconds.strip().split(" ", 1)[0]
hsec = int(hours)*3600
msec = int(minutes)*60
ttime = ttime+hsec+msec+int(seconds)
mins = ttime/60
secs = ttime%60
hrs = mins/60
mins = mins%60
days = hrs/24
hrs = hrs%24
print "Total merge time:"
print output.green("\t%s days, %s hours, %s minutes and %s seconds" % (days, hrs, mins, secs))
Then run:
chmod +x /usr/bin/genlop-total genlop-total
Cheers, ObsidianX
Note: Change the first for loop, as shown below, will allow the script to function in case you have a log error (merge time: log error; merge time unknown):
for i in genlops:
if i != '':
if i.strip().startswith("merge time") and not "log error" in i.strip():
genlop2.append(i.strip())
