Skip to content

Commit

Permalink
patman: Don't clear progress in tout unless it was used
Browse files Browse the repository at this point in the history
At present calling Uninit() always called ClearProgress() which outputs
a \r character as well as spaces to remove any progress information on the
line. This can mess up the normal output of binman and other tools. Fix
this by outputing this only when progress information has actually been
previous written.

Signed-off-by: Simon Glass <[email protected]>
  • Loading branch information
sjg20 committed Oct 8, 2018
1 parent 1fda182 commit 008b030
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tools/patman/tout.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
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
Expand Down Expand Up @@ -48,23 +50,27 @@ 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.
Args:
msg: Message to display.
warning: True if this is a warning."""
global in_progress
ClearProgress()
if verbose > 0:
_progress = msg + trailer
if stdout_is_tty:
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')

Expand Down

0 comments on commit 008b030

Please sign in to comment.