+def list_emerge_processes():
+ """Look for the ebuild process with ps. If the process is found parse
+ the command for the package. With this package search the LOGFILE for
+ the emerge startup time."""
+
+ f = open_log()
+
+ now = datetime.datetime.today()
+
+ for i in os.popen("ps ax"):
+ if (("ebuild.sh" in i) and ("/bin/bash" not in i)):
+ pack = i.partition('[')[2].partition(']')[0]
+
+ version = pack.partition('/')[2].partition('-')[2]
+
+ while not version[0].isdigit():
+ version = version.partition('-')[2]
+
+ package_name = pack[:-len(version)-1]
+
+ packages.append(package(package_name, version))
+
+
+ if len(packages) == 0:
+ print "No current emerge process found."
+ return
+
+
+ for line in f:
+ if ((">>>" in line) and ("emerge" in line)):
+ for p in packages:
+ if (p.name + '-' + p.version in line):
+
+ time = float(line.partition(' ')[0].strip(":"))
+
+ timestamp = datetime.datetime.fromtimestamp(time)
+ difference = (now - timestamp).total_seconds()
+
+ if difference < p.emerge_time:
+ p.emerge_time = difference
+
+
+
+