Merge tag 'dm-9oct18' of git://git.denx.de/u-boot-dm
[platform/kernel/u-boot.git] / tools / patman / tout.py
index c5fbd80..4957c7a 100644 (file)
@@ -1,7 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
 # Copyright (c) 2016 Google, Inc
 #
-# SPDX-License-Identifier:            GPL-2.0+
-#
 # Terminal output logging.
 #
 
@@ -16,6 +15,8 @@ NOTICE = 2
 INFO = 3
 DEBUG = 4
 
+in_progress = False
+
 """
 This class handles output of progress and other useful information
 to the user. It provides for simple verbosity level control and can
@@ -49,9 +50,11 @@ def UserIsPresent():
 
 def ClearProgress():
     """Clear any active progress message on the terminal."""
-    if verbose > 0 and stdout_is_tty:
+    global in_progress
+    if verbose > 0 and stdout_is_tty and in_progress:
         _stdout.write('\r%s\r' % (" " * len (_progress)))
         _stdout.flush()
+        in_progress = False
 
 def Progress(msg, warning=False, trailer='...'):
     """Display progress information.
@@ -59,6 +62,7 @@ def Progress(msg, warning=False, trailer='...'):
     Args:
         msg: Message to display.
         warning: True if this is a warning."""
+    global in_progress
     ClearProgress()
     if verbose > 0:
         _progress = msg + trailer
@@ -66,6 +70,7 @@ def Progress(msg, warning=False, trailer='...'):
             col = _color.YELLOW if warning else _color.GREEN
             _stdout.write('\r' + _color.Color(col, _progress))
             _stdout.flush()
+            in_progress = True
         else:
             _stdout.write(_progress + '\n')