]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bitbake: knotty: Pretty print task elapsed time
authorJacob Kroon <jacob.kroon@gmail.com>
Fri, 26 Apr 2019 21:37:27 +0000 (23:37 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 30 Apr 2019 11:05:24 +0000 (12:05 +0100)
A task's runtime is currently printed in seconds. Change it to
include minutes and hours for easier reading.

(Bitbake rev: c593ae5ec9fecd4bde823948024e4d56314a60ce)

Signed-off-by: Jacob Kroon <jacob.kroon@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/bb/ui/knotty.py

index fa88e6ccdd32d93d0aeaded9c029c130aa36fa79..f362c23afc5225923c365da1570adc83d8460299 100644 (file)
@@ -222,6 +222,18 @@ class TerminalFilter(object):
             sys.stdout.flush()
         self.footer_present = False
 
+    def elapsed(self, sec):
+        hrs = int(sec / 3600.0)
+        sec -= hrs * 3600
+        min = int(sec / 60.0)
+        sec -= min * 60
+        if hrs > 0:
+            return "%dh%dm%ds" % (hrs, min, sec)
+        elif min > 0:
+            return "%dm%ds" % (min, sec)
+        else:
+            return "%ds" % (sec)
+
     def updateFooter(self):
         if not self.cuu:
             return
@@ -258,7 +270,7 @@ class TerminalFilter(object):
             else:
                 start_time = activetasks[t].get("starttime", None)
                 if start_time:
-                    tasks.append("%s - %ds (pid %s)" % (activetasks[t]["title"], currenttime - start_time, t))
+                    tasks.append("%s - %s (pid %s)" % (activetasks[t]["title"], self.elapsed(currenttime - start_time), t))
                 else:
                     tasks.append("%s (pid %s)" % (activetasks[t]["title"], t))