From 913327f10c73c53edca6421a48c116b87b207b15 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Mon, 5 Jun 2017 15:01:41 +0200 Subject: [PATCH] Add a newline after "Fetching projects" progress output Output before change: Fetching project platform/packages/providers/UserDictionaryProvider Fetching projects: 66% (773/1171) Fetching project platform/external/regex-re2 Fetching project device/generic/mini-emulator-x86_64 Output after change: Fetching project platform/packages/providers/UserDictionaryProvider Fetching projects: 66% (773/1171) Fetching project platform/external/regex-re2 Fetching project device/generic/mini-emulator-x86_64 Change-Id: I4da84da58316c69294e4da2792f83885dc942701 --- progress.py | 8 +++++--- subcmds/sync.py | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/progress.py b/progress.py index d948654f..b08f52e5 100644 --- a/progress.py +++ b/progress.py @@ -21,7 +21,7 @@ from trace import IsTrace _NOT_TTY = not os.isatty(2) class Progress(object): - def __init__(self, title, total=0, units=''): + def __init__(self, title, total=0, units='', print_newline=False): self._title = title self._total = total self._done = 0 @@ -29,6 +29,7 @@ class Progress(object): self._start = time() self._show = False self._units = units + self._print_newline = print_newline def update(self, inc=1): self._done += inc @@ -52,11 +53,12 @@ class Progress(object): if self._lastp != p: self._lastp = p - sys.stderr.write('\r%s: %3d%% (%d%s/%d%s) ' % ( + sys.stderr.write('\r%s: %3d%% (%d%s/%d%s)%s' % ( self._title, p, self._done, self._units, - self._total, self._units)) + self._total, self._units, + "\n" if self._print_newline else "")) sys.stderr.flush() def end(self): diff --git a/subcmds/sync.py b/subcmds/sync.py index ef023274..eabe16aa 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -356,7 +356,8 @@ later is required to fix a server side protocol bug. def _Fetch(self, projects, opt): fetched = set() lock = _threading.Lock() - pm = Progress('Fetching projects', len(projects)) + pm = Progress('Fetching projects', len(projects), + print_newline=not(opt.quiet)) objdir_project_map = dict() for project in projects: