Skip to contentSkip to conversation

knotty: Some improvements to TerminalFilter.updateFooter()

PATCH New Peter Kjellerstedt 1 participant 2 messages Oct 25, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 knotty: Some improvements to TerminalFilter.updateFooter()

* Correct/improve a couple of comments.
* Iterate over the values (tasks) of activetasks rather than the keys (TIDs) as the TIDs were only used to lookup the tasks.

---

PATCHv2: No changes.

 bitbake/lib/bb/ui/knotty.py | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
bitbake/lib/bb/ui/knotty.py +14 -14
index 00258c80ff..6f03bf2faa 100644
@@ -260,16 +260,16 @@ class TerminalFilter(object):
             self.helper.needUpdate = True
             need_update = self.helper.needUpdate
         else:
-            # Do not let to update faster then _DEFAULT_PRINT_INTERVAL
+            # Do not update faster than _DEFAULT_PRINT_INTERVAL
             # to avoid heavy print() flooding.
             need_update = self.helper.needUpdate and (deltatime > self._DEFAULT_PRINT_INTERVAL)
 
-        if self.footer_present and (not need_update):
-            # Footer update is not need.
+        if self.footer_present and not need_update:
+            # Footer update is not needed.
             return
-        else:
-            # Footer update is need and store its "lasttime" value.
-            self.lasttime = currenttime
+ 
+        # Remember the time when the footer was last updated.
+        self.lasttime = currenttime
 
         self.helper.needUpdate = False
         if (not self.helper.tasknumber_total or self.helper.tasknumber_current == self.helper.tasknumber_total) and not len(activetasks):
@@ -281,16 +281,16 @@ class TerminalFilter(object):
         self._footer_buf.seek(0)
 
         tasks = []
-        for t in activetasks.keys():
-            start_time = activetasks[t].get("starttime", None)
+        for task in activetasks.values():
+            start_time = task.get("starttime", None)
             if start_time:
-                msg = "%s - %s (pid %s)" % (activetasks[t]["title"], self.elapsed(currenttime - start_time), activetasks[t]["pid"])
+                msg = "%s - %s (pid %s)" % (task["title"], self.elapsed(currenttime - start_time), task["pid"])
             else:
-                msg = "%s (pid %s)" % (activetasks[t]["title"], activetasks[t]["pid"])
-            progress = activetasks[t].get("progress", None)
+                msg = "%s (pid %s)" % (task["title"], task["pid"])
+            progress = task.get("progress", None)
             if progress is not None:
-                pbar = activetasks[t].get("progressbar", None)
-                rate = activetasks[t].get("rate", None)
+                pbar = task.get("progressbar", None)
+                rate = task.get("rate", None)
                 if not pbar or pbar.bouncing != (progress < 0):
                     if progress < 0:
                         pbar = BBProgress("0: %s" % msg, 100, widgets=[' ', progressbar.BouncingSlider(), ''], extrapos=3, resize_handler=self.sigwinch_handle)
@@ -299,7 +299,7 @@ class TerminalFilter(object):
                         pbar = BBProgress("0: %s" % msg, 100, widgets=[' ', progressbar.Percentage(), ' ', progressbar.Bar(), ''], extrapos=5, resize_handler=self.sigwinch_handle)
                         pbar.bouncing = False
                     pbar.fd = self._footer_buf
-                    activetasks[t]["progressbar"] = pbar
+                    task["progressbar"] = pbar
                 tasks.append((pbar, msg, progress, rate, start_time))
             else:
                 tasks.append(msg)
#1 lore raw

PATCH v2 2/2 knotty, teamcity, tinfoil: Only allow one process progress bar at once

In case a process progress bar (e.g., "Initialising tasks") is active when a new one (e.g., "Checking sstate mirror object availability") is started, then finish the first one before starting the second. Also ignore ProcessProgress and ProcessFinished events that are not for the currently active progress bar.

This also adds an id to BBProgress (initialized to the initial msg), which is not affected by calls to setmessage().

---

PATCHv2: Corrected a typo (parseprogress,finish -> parseprogress.finish)

 bitbake/lib/bb/tinfoil.py     | 10 +++++-----
 bitbake/lib/bb/ui/knotty.py   | 12 +++++++-----
 bitbake/lib/bb/ui/teamcity.py | 14 +++++++++++---
 3 files changed, 23 insertions(+), 13 deletions(-)
bitbake/lib/bb/tinfoil.py +5 -5
index e7fbcbca0a..d9e985c612 100644
@@ -91,23 +91,23 @@ def wait_for(f):
                             if isinstance(event, bb.event.ProcessStarted):
                                 if self.quiet > 1:
                                     continue
+                                if parseprogress:
+                                    parseprogress.finish()
                                 parseprogress = bb.ui.knotty.new_progress(event.processname, event.total)
                                 parseprogress.start(False)
                                 continue
                             if isinstance(event, bb.event.ProcessProgress):
                                 if self.quiet > 1:
                                     continue
-                                if parseprogress:
+                                if parseprogress and parseprogress.id == event.processname:
                                     parseprogress.update(event.progress)
-                                else:
-                                    bb.warn("Got ProcessProgress event for something that never started?")
                                 continue
                             if isinstance(event, bb.event.ProcessFinished):
                                 if self.quiet > 1:
                                     continue
-                                if parseprogress:
+                                if parseprogress and parseprogress.id == event.processname:
                                     parseprogress.finish()
-                                parseprogress = None
+                                    parseprogress = None
                                 continue
                             if isinstance(event, bb.command.CommandCompleted):
                                 result = True
bitbake/lib/bb/ui/knotty.py +7 -5
index 6f03bf2faa..4bcf6bd12f 100644
@@ -39,6 +39,7 @@ interactive = sys.stdout.isatty()
 
 class BBProgress(progressbar.ProgressBar):
     def __init__(self, msg, maxval, widgets=None, extrapos=-1, resize_handler=None):
+        self.id = msg
         self.msg = msg
         self.extrapos = extrapos
         if not widgets:
@@ -84,6 +85,7 @@ class NonInteractiveProgress(object):
     fobj = sys.stdout
 
     def __init__(self, msg, maxval):
+        self.id = msg
         self.msg = msg
         self.maxval = maxval
         self.finished = False
@@ -886,23 +888,23 @@ def main(server, eventHandler, params, tf = TerminalFilter):
                 if params.options.quiet > 1:
                     continue
                 termfilter.clearFooter()
+                if parseprogress:
+                    parseprogress.finish()
                 parseprogress = new_progress(event.processname, event.total)
                 parseprogress.start(False)
                 continue
             if isinstance(event, bb.event.ProcessProgress):
                 if params.options.quiet > 1:
                     continue
-                if parseprogress:
+                if parseprogress and parseprogress.id == event.processname:
                     parseprogress.update(event.progress)
-                else:
-                    bb.warn("Got ProcessProgress event for someting that never started?")
                 continue
             if isinstance(event, bb.event.ProcessFinished):
                 if params.options.quiet > 1:
                     continue
-                if parseprogress:
+                if parseprogress and parseprogress.id == event.processname:
                     parseprogress.finish()
-                parseprogress = None
+                    parseprogress = None
                 continue
 
             # ignore
bitbake/lib/bb/ui/teamcity.py +11 -3
index 7eeaab8d63..3177f4aaf4 100644
@@ -200,6 +200,7 @@ def main(server, eventHandler, params):
         logger.error("XMLRPC Fault getting commandline: {0}".format(x))
         return 1
 
+    active_process = None
     active_process_total = None
     is_tasks_running = False
 
@@ -300,16 +301,23 @@ def main(server, eventHandler, params):
 
             if isinstance(event, bb.event.ProcessStarted):
                 if event.processname in ["Initialising tasks", "Checking sstate mirror object availability"]:
+                    if active_process:
+                        ui.progress(active_process, 100)
+                        ui.block_end()
+                    active_process = event.processname
                     active_process_total = event.total
                     ui.block_start(event.processname)
             if isinstance(event, bb.event.ProcessFinished):
                 if event.processname in ["Initialising tasks", "Checking sstate mirror object availability"]:
-                    ui.progress(event.processname, 100)
-                    ui.block_end()
+                    if active_process and active_process == event.processname:
+                        ui.progress(event.processname, 100)
+                        ui.block_end()
+                        active_process = None
             if isinstance(event, bb.event.ProcessProgress):
                 if event.processname in ["Initialising tasks",
                                          "Checking sstate mirror object availability"] and active_process_total != 0:
-                    ui.progress(event.processname, event.progress * 100 / active_process_total)
+                    if active_process and active_process == event.processname:
+                        ui.progress(event.processname, event.progress * 100 / active_process_total)
             if isinstance(event, bb.event.CacheLoadStarted):
                 ui.block_start("Loading cache")
             if isinstance(event, bb.event.CacheLoadProgress):