diff options
-rw-r--r-- | progress.py | 8 | ||||
-rw-r--r-- | 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 | |||
21 | _NOT_TTY = not os.isatty(2) | 21 | _NOT_TTY = not os.isatty(2) |
22 | 22 | ||
23 | class Progress(object): | 23 | class Progress(object): |
24 | def __init__(self, title, total=0, units=''): | 24 | def __init__(self, title, total=0, units='', print_newline=False): |
25 | self._title = title | 25 | self._title = title |
26 | self._total = total | 26 | self._total = total |
27 | self._done = 0 | 27 | self._done = 0 |
@@ -29,6 +29,7 @@ class Progress(object): | |||
29 | self._start = time() | 29 | self._start = time() |
30 | self._show = False | 30 | self._show = False |
31 | self._units = units | 31 | self._units = units |
32 | self._print_newline = print_newline | ||
32 | 33 | ||
33 | def update(self, inc=1): | 34 | def update(self, inc=1): |
34 | self._done += inc | 35 | self._done += inc |
@@ -52,11 +53,12 @@ class Progress(object): | |||
52 | 53 | ||
53 | if self._lastp != p: | 54 | if self._lastp != p: |
54 | self._lastp = p | 55 | self._lastp = p |
55 | sys.stderr.write('\r%s: %3d%% (%d%s/%d%s) ' % ( | 56 | sys.stderr.write('\r%s: %3d%% (%d%s/%d%s)%s' % ( |
56 | self._title, | 57 | self._title, |
57 | p, | 58 | p, |
58 | self._done, self._units, | 59 | self._done, self._units, |
59 | self._total, self._units)) | 60 | self._total, self._units, |
61 | "\n" if self._print_newline else "")) | ||
60 | sys.stderr.flush() | 62 | sys.stderr.flush() |
61 | 63 | ||
62 | def end(self): | 64 | 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. | |||
356 | def _Fetch(self, projects, opt): | 356 | def _Fetch(self, projects, opt): |
357 | fetched = set() | 357 | fetched = set() |
358 | lock = _threading.Lock() | 358 | lock = _threading.Lock() |
359 | pm = Progress('Fetching projects', len(projects)) | 359 | pm = Progress('Fetching projects', len(projects), |
360 | print_newline=not(opt.quiet)) | ||
360 | 361 | ||
361 | objdir_project_map = dict() | 362 | objdir_project_map = dict() |
362 | for project in projects: | 363 | for project in projects: |