knotty.py: Improve the message while waiting for running tasks to finish
PATCH v2 1/3 knotty.py: Improve the message while waiting for running tasks to finish
From: Peter Kjellerstedt <[email protected]>
Use pluralise() to correct the grammar, and drop the colon at the end if runnning in quiet mode.
---
PATCHv2: No changes.
bitbake/lib/bb/ui/knotty.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
bitbake/lib/bb/ui/knotty.py +4 -1
@@ -272,7 +272,10 @@ class TerminalFilter(object): tasks.append("%s (pid %s)" % (activetasks[t]["title"], activetasks[t]["pid"])) if self.main.shutdown: - content = "Waiting for %s running tasks to finish:" % len(activetasks) + content = pluralise("Waiting for %s running task to finish", + "Waiting for %s running tasks to finish", len(activetasks)) + if not self.quiet: + content += ':' print(content) else: if self.quiet:
PATCH v2 2/3 knotty.py: Correct the width of the progress bar for the real tasks
From: Peter Kjellerstedt <[email protected]>
In commit 8055ec36 (knotty: Improve setscene task display) the setscene tasks got their own line in the task output. However, the progress bar code does not handle newlines in its widgets, so the length of the setscene line was included when calculating how much space is available for the progress bar of the running tasks, making it much too short.
Instead of trying to teach the progress bar code to handle newlines, separate the output of the setscene tasks from the progress bar for the real tasks.
---
PATCHv2: Corrected so that there are no changes to the output except
that the progress bar now fills the width of the terminal as expected.
bitbake/lib/bb/ui/knotty.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
bitbake/lib/bb/ui/knotty.py +16 -9
@@ -278,25 +278,32 @@ class TerminalFilter(object): content += ':' print(content) else: + scene_tasks = "%s of %s" % (self.helper.setscene_current, self.helper.setscene_total) + cur_tasks = "%s of %s" % (self.helper.tasknumber_current, self.helper.tasknumber_total) + + content = '' + if not self.quiet: + msg = "Setscene tasks: %s" % scene_tasks + content += msg + "\n" + print(msg) + if self.quiet: - content = "Running tasks (%s of %s, %s of %s)" % (self.helper.setscene_current, self.helper.setscene_total, self.helper.tasknumber_current, self.helper.tasknumber_total) + msg = "Running tasks (%s, %s)" % (scene_tasks, cur_tasks) elif not len(activetasks): - content = "Setscene tasks: %s of %s\nNo currently running tasks (%s of %s)" % (self.helper.setscene_current, self.helper.setscene_total, self.helper.tasknumber_current, self.helper.tasknumber_total) + msg = "No currently running tasks (%s)" % cur_tasks else: - content = "Setscene tasks: %s of %s\nCurrently %2s running tasks (%s of %s)" % (self.helper.setscene_current, self.helper.setscene_total, len(activetasks), self.helper.tasknumber_current, self.helper.tasknumber_total) + 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()] self.main_progress = BBProgress("Running tasks", maxtask, widgets=widgets, resize_handler=self.sigwinch_handle) self.main_progress.start(False) - self.main_progress.setmessage(content) - progress = self.helper.tasknumber_current - 1 - if progress < 0: - progress = 0 - content = self.main_progress.update(progress) + self.main_progress.setmessage(msg) + progress = max(0, self.helper.tasknumber_current - 1) + content += self.main_progress.update(progress) print('') lines = self.getlines(content) - if self.quiet == 0: + if not self.quiet: for tasknum, task in enumerate(tasks[:(self.rows - 1 - lines)]): if isinstance(task, tuple): pbar, progress, rate, start_time = task
PATCH v2 3/3 knotty.py: Unify quiet and non-quiet output for the running tasks
In reply to Peter KjellerstedtFrom: Peter Kjellerstedt <[email protected]>
This adds the number of currently running tasks to the output in quiet mode, and removes the word "currently" from the output for the non-quiet output. Removing "currently" avoids having the text "jump around" depending on whether any tasks are running or not, and it also gives a little bit more space to the progress bar.
---
PATCHv2: New.
bitbake/lib/bb/ui/knotty.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
bitbake/lib/bb/ui/knotty.py +3 -4
@@ -287,12 +287,11 @@ class TerminalFilter(object): content += msg + "\n" print(msg) + msg = "%2s running tasks" % (len(activetasks) or "No") if self.quiet: - msg = "Running tasks (%s, %s)" % (scene_tasks, cur_tasks) - elif not len(activetasks): - msg = "No currently running tasks (%s)" % cur_tasks + msg += " (%s, %s)" % (scene_tasks, cur_tasks) else: - msg = "Currently %2s running tasks (%s)" % (len(activetasks), cur_tasks) + msg += " (%s)" % cur_tasks maxtask = self.helper.tasknumber_total if not self.main_progress or self.main_progress.maxval != maxtask: widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar()]