Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Unified Diff: third_party/repo/progress.py

Issue 3497013: Display the name of the repository that is being updated. (Closed)
Patch Set: Simplify check for text to output. Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gclient_utils.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/repo/progress.py
diff --git a/third_party/repo/progress.py b/third_party/repo/progress.py
index 860d9d01125237f06d72c72c5dce94b325209e68..3d302814c2c6b175c2966d5db82b6666539d9370 100644
--- a/third_party/repo/progress.py
+++ b/third_party/repo/progress.py
@@ -24,8 +24,9 @@ class Progress(object):
self._lastp = -1
self._start = time()
self._show = False
+ self._width = 0
- def update(self, inc=1):
+ def update(self, inc=1, extra=''):
self._done += inc
if not self._show:
@@ -34,35 +35,37 @@ class Progress(object):
else:
return
+ text = None
+
if self._total <= 0:
- sys.stdout.write('\r%s: %d, ' % (
- self._title,
- self._done))
- sys.stdout.flush()
+ text = '%s: %3d' % (self._title, self._done)
else:
p = (100 * self._done) / self._total
if self._lastp != p:
self._lastp = p
- sys.stdout.write('\r%s: %3d%% (%d/%d) ' % (
- self._title,
- p,
- self._done,
- self._total))
- sys.stdout.flush()
+ text = '%s: %3d%% (%2d/%2d)' % (self._title, p,
+ self._done, self._total)
+
+ if text:
+ text += ' ' + extra
+ spaces = max(self._width - len(text), 0)
+ sys.stdout.write('%s%*s\r' % (text, spaces, ''))
+ sys.stdout.flush()
+ self._width = len(text)
def end(self):
if not self._show:
return
if self._total <= 0:
- sys.stdout.write('\r%s: %d, done. \n' % (
+ sys.stdout.write('%s: %d, done.\n' % (
self._title,
self._done))
sys.stdout.flush()
else:
p = (100 * self._done) / self._total
- sys.stdout.write('\r%s: %3d%% (%d/%d), done. \n' % (
+ sys.stdout.write('%s: %3d%% (%d/%d), done.\n' % (
self._title,
p,
self._done,
« no previous file with comments | « gclient_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698