self.versions = []
self.emerge_time = "infinity"
+ self.plotData = []
+
def add_version(self, version, emerge_time, emerge_date):
"""Add version to the class version list"""
if len(give_time(p[1], True)) > time_length:
time_length = len(give_time(p[1], True))
+ # Create the data for plotting in the format (emerge time, emerge date)
+ self.plotData.append((p[1], p[2]))
+
dots = (version_length + time_length + len(self.name)
+ len(give_date(self.versions[0][2])) + 14)
"\nIn total spent:\t" + give_time(total) +
"emerging " + GREEN(self.name))
+ def plotToScreen(self):
+ dates = []
+ times = []
+
+ for i in self.plotData:
+ dates.append(datetime.date.fromtimestamp(i[1]))
+ times.append(i[0])
+
+ fig = plt.figure()
+
+ plt.plot_date(dates, times, xdate=True, ydate=False)
+
+ plt.ylabel("Emerge time [s]")
+ plt.suptitle(self.name)
+ plt.grid()
+ fig.autofmt_xdate()
+ plt.show()
+
def give_time(time, nocolor=False):
elif ((":::" in line) and ("completed emerge" in line)):
for p in all_packages:
if p[0] in line:
- stop_time = float(line.partition(':')[0])
-
print("\t" + give_date(p[1]) + " >>> " + GREEN(p[0]))
- total_emerge_time += stop_time - p[1]
emerge_number += 1
all_packages.pop(all_packages.index(p))
- print("\n" + GREEN(str(emerge_number)) + " packages in total.")
++
+ print("\n" + GREEN(str(emerge_number)) + " emerges in total found.")
pack.print_versions()
pack.print_min_max_ave()
+ if matplotWorking:
+ pack.plotToScreen()
+
else:
print("Package " + GREEN(pack.name)
+ " has never been emerged.")
\t-h, --help \t Show this helpscreen
\t-q, --quiet \t Be less verbose
\t--no-color \t Use colorless output
+\t--plot \t\t Plot emerge times into a 2D scatter plot
+\t\t\t (needs matlibplot installed for this to work)
\t--simulate \t Do a simulation run"""
print usage
mode = "package"
input_packages = None
simulation = False
+ matplotWorking = False
for arg in sys.argv[1:]:
sys.argv.pop(sys.argv.index(arg))
+ if arg == "--plot":
+ try:
+ import matplotlib.pyplot as plt
+ matplotWorking = True
+ except ImportError:
+ print(RED("Cannot initialize matplotlib!"))
+ print(RED("Check that you have properly installed matplotlib.\n"))
+ matplotWorking = False
+
+ sys.argv.pop(sys.argv.index(arg))
+
if arg == "--no-color":
green_start = ""
color_stop = ""