diff mbox series

[v3,21/27] moveconfig: Show failures in progress

Message ID 20230923194424.1739224-22-sjg@chromium.org
State Accepted
Commit 6b25d21c8657c4c72dacbec547f560eb8579199e
Delegated to: Simon Glass
Headers show
Series moveconfig: Drop old code and tidy up | expand

Commit Message

Simon Glass Sept. 23, 2023, 7:44 p.m. UTC
Show the number of accumulated failures when processing. Use a shorter
format with colour.

An unwanted space appears before the defconfig name on every item except
the last. Fix that while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 tools/moveconfig.py | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

Comments

Simon Glass Oct. 4, 2023, 5:58 p.m. UTC | #1
Show the number of accumulated failures when processing. Use a shorter
format with colour.

An unwanted space appears before the defconfig name on every item except
the last. Fix that while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 tools/moveconfig.py | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

Applied to u-boot-dm, thanks!
Simon Glass Oct. 7, 2023, 8:37 p.m. UTC | #2
Show the number of accumulated failures when processing. Use a shorter
format with colour.

An unwanted space appears before the defconfig name on every item except
the last. Fix that while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 tools/moveconfig.py | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

Applied to u-boot-dm, thanks!
Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/tools/moveconfig.py b/tools/moveconfig.py
index 9e9cb672a967..2a4badf8649a 100755
--- a/tools/moveconfig.py
+++ b/tools/moveconfig.py
@@ -241,24 +241,36 @@  class Progress:
 
     """Progress Indicator"""
 
-    def __init__(self, total):
+    def __init__(self, col, total):
         """Create a new progress indicator.
 
         Args:
-          total: A number of defconfig files to process.
+            color_enabled (bool): True for colour output
+            total (int): A number of defconfig files to process.
         """
+        self.col = col
         self.current = 0
+        self.good = 0
         self.total = total
 
-    def inc(self):
-        """Increment the number of processed defconfig files."""
+    def inc(self, success):
+        """Increment the number of processed defconfig files.
 
+        Args:
+            success (bool): True if processing succeeded
+        """
+        self.good += success
         self.current += 1
 
     def show(self):
         """Display the progress."""
         if self.current != self.total:
-            print(f' {self.current} defconfigs out of {self.total}\r', end=' ')
+            line = self.col.build(self.col.GREEN, f'{self.good:5d}')
+            line += self.col.build(self.col.RED,
+                                   f'{self.current - self.good:5d}')
+            line += self.col.build(self.col.MAGENTA,
+                                   f'/{self.total - self.current}')
+            print(f'{line}  \r', end='')
         sys.stdout.flush()
 
 
@@ -578,7 +590,7 @@  class Slot:
             # Record the failed board.
             self.failed_boards.add(self.defconfig)
 
-        self.progress.inc()
+        self.progress.inc(success)
         self.progress.show()
         self.state = STATE_IDLE
 
@@ -729,7 +741,7 @@  def move_config(toolchains, args, db_queue, col):
     else:
         defconfigs = get_all_defconfigs()
 
-    progress = Progress(len(defconfigs))
+    progress = Progress(col, len(defconfigs))
     slots = Slots(toolchains, args, progress, reference_src_dir, db_queue, col)
 
     # Main loop to process defconfig files: