diff mbox

[U-Boot,4/5] tools: moveconfig: simplify show_failed_boards() and show more info

Message ID 1465968834-17361-5-git-send-email-yamada.masahiro@socionext.com
State Accepted
Commit 96dccd9767311f4b8e585fd9e33fcb2a09e36951
Delegated to: Masahiro Yamada
Headers show

Commit Message

Masahiro Yamada June 15, 2016, 5:33 a.m. UTC
Since commit 1d085568b3de ("tools: moveconfig: display log atomically
in more readable format"), the function color_text() is clever enough
to exclude LF from escape sequences.  Exploit it for removing the
"for" loops from Slots.show_failed_boards().

Also, display "(the list has been saved in moveconfig.failed)" if
there are failed boards.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 tools/moveconfig.py | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

Comments

Joe Hershberger June 20, 2016, 9:35 p.m. UTC | #1
On Wed, Jun 15, 2016 at 12:33 AM, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> Since commit 1d085568b3de ("tools: moveconfig: display log atomically
> in more readable format"), the function color_text() is clever enough
> to exclude LF from escape sequences.  Exploit it for removing the
> "for" loops from Slots.show_failed_boards().
>
> Also, display "(the list has been saved in moveconfig.failed)" if
> there are failed boards.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
diff mbox

Patch

diff --git a/tools/moveconfig.py b/tools/moveconfig.py
index 0e03751..f795a7f 100755
--- a/tools/moveconfig.py
+++ b/tools/moveconfig.py
@@ -860,21 +860,22 @@  class Slots:
 
     def show_failed_boards(self):
         """Display all of the failed boards (defconfigs)."""
-        failed_boards = []
+        boards = []
+        output_file = 'moveconfig.failed'
 
         for slot in self.slots:
-            failed_boards += slot.get_failed_boards()
-
-        if len(failed_boards) > 0:
-            msg = [ "The following boards were not processed due to error:" ]
-            msg += failed_boards
-            for line in msg:
-                print >> sys.stderr, color_text(self.options.color,
-                                                COLOR_LIGHT_RED, line)
-
-            with open('moveconfig.failed', 'w') as f:
-                for board in failed_boards:
-                    f.write(board + '\n')
+            boards += slot.get_failed_boards()
+
+        if boards:
+            boards = '\n'.join(boards) + '\n'
+            msg = "The following boards were not processed due to error:\n"
+            msg += boards
+            msg += "(the list has been saved in %s)\n" % output_file
+            print >> sys.stderr, color_text(self.options.color, COLOR_LIGHT_RED,
+                                            msg)
+
+            with open(output_file, 'w') as f:
+                f.write(boards)
 
 class ReferenceSource: