[PATCH] knotty: show elapsed time on the task progress bar
"WXbet" <[email protected]>
| Newsgroups | org.openembedded.lists.bitbake-devel |
|---|---|
| Message-ID | <[email protected]> |
As a convenience for the user, this makes it easy to see at a glance how long the current build has already been running. The progress bar for the overall build currently shows only a percentage and a bar, with no running time — while each individual running-task line below it already carries an elapsed-time value. The patch adds a Timer widget to the bar, reusing knotty's existing time formatting so it matches the rest of the UI. Thanks, WXbet
0001-knotty-show-elapsed-time-on-the-task-progress-bar.patch
(application/octet-stream, 2.8 KB)
From 9302e85e75edc6af22ea90336d2b0c46fa95fe80 Mon Sep 17 00:00:00 2001 From: WXbet <[email protected]> Date: Tue, 18 Aug 2026 21:30:22 +0200 Subject: [PATCH] knotty: show elapsed time on the task progress bar The progress bar for the overall build shows a percentage and a bar but no elapsed time, even though the individual running-task lines below it each show one. Add a Timer widget to the bar. The time formatting in TerminalFilter.elapsed() is hoisted to a module-level bb_elapsed() helper and reused by a small progressbar.Timer subclass, so the bar prints the same "%dh%dm%ds" style as the rest of the UI. Signed-off-by: WXbet <[email protected]> --- lib/bb/ui/knotty.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/bb/ui/knotty.py b/lib/bb/ui/knotty.py index 15025e8dd..343045881 100644 --- a/lib/bb/ui/knotty.py +++ b/lib/bb/ui/knotty.py @@ -37,6 +37,21 @@ featureSet = [bb.cooker.CookerFeatures.SEND_SANITYEVENTS, bb.cooker.CookerFeatur logger = logging.getLogger("BitBake") interactive = sys.stdout.isatty() +def bb_elapsed(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) + +class BBTimer(progressbar.Timer): + format_time = staticmethod(bb_elapsed) + class BBProgress(progressbar.ProgressBar): def __init__(self, msg, maxval, widgets=None, extrapos=-1, resize_handler=None): self.id = msg @@ -250,16 +265,7 @@ class TerminalFilter(object): self._footer_lines = None 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) + return bb_elapsed(sec) def keepAlive(self, t): if not self.cuu: @@ -354,7 +360,7 @@ class TerminalFilter(object): msg = "Currently %2s running tasks (%s)" % (len(activetasks), cur_tasks) maxtask = self.helper.tasknumber_total if not self.main_progress or self.main_progress.maxval != maxtask: - widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar()] + widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar(), ' ', BBTimer(format='Elapsed: %s')] self.main_progress = BBProgress("Running tasks", maxtask, widgets=widgets, resize_handler=self.sigwinch_handle) self.main_progress.fd = self._footer_buf self.main_progress.start(False) -- 2.53.0