diff options
| -rw-r--r-- | progress.py | 26 | ||||
| -rw-r--r-- | subcmds/sync.py | 3 |
2 files changed, 11 insertions, 18 deletions
diff --git a/progress.py b/progress.py index 9222fcfc..3764b9e2 100644 --- a/progress.py +++ b/progress.py | |||
| @@ -26,17 +26,14 @@ CSI_ERASE_LINE = '\x1b[2K' | |||
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | class Progress(object): | 28 | class Progress(object): |
| 29 | def __init__(self, title, total=0, units='', print_newline=False, | 29 | def __init__(self, title, total=0, units='', print_newline=False): |
| 30 | always_print_percentage=False): | ||
| 31 | self._title = title | 30 | self._title = title |
| 32 | self._total = total | 31 | self._total = total |
| 33 | self._done = 0 | 32 | self._done = 0 |
| 34 | self._lastp = -1 | ||
| 35 | self._start = time() | 33 | self._start = time() |
| 36 | self._show = False | 34 | self._show = False |
| 37 | self._units = units | 35 | self._units = units |
| 38 | self._print_newline = print_newline | 36 | self._print_newline = print_newline |
| 39 | self._always_print_percentage = always_print_percentage | ||
| 40 | 37 | ||
| 41 | def update(self, inc=1, msg=''): | 38 | def update(self, inc=1, msg=''): |
| 42 | self._done += inc | 39 | self._done += inc |
| @@ -58,18 +55,15 @@ class Progress(object): | |||
| 58 | sys.stderr.flush() | 55 | sys.stderr.flush() |
| 59 | else: | 56 | else: |
| 60 | p = (100 * self._done) / self._total | 57 | p = (100 * self._done) / self._total |
| 61 | 58 | sys.stderr.write('%s\r%s: %3d%% (%d%s/%d%s)%s%s%s' % ( | |
| 62 | if self._lastp != p or self._always_print_percentage: | 59 | CSI_ERASE_LINE, |
| 63 | self._lastp = p | 60 | self._title, |
| 64 | sys.stderr.write('%s\r%s: %3d%% (%d%s/%d%s)%s%s%s' % ( | 61 | p, |
| 65 | CSI_ERASE_LINE, | 62 | self._done, self._units, |
| 66 | self._title, | 63 | self._total, self._units, |
| 67 | p, | 64 | ' ' if msg else '', msg, |
| 68 | self._done, self._units, | 65 | '\n' if self._print_newline else '')) |
| 69 | self._total, self._units, | 66 | sys.stderr.flush() |
| 70 | ' ' if msg else '', msg, | ||
| 71 | "\n" if self._print_newline else "")) | ||
| 72 | sys.stderr.flush() | ||
| 73 | 67 | ||
| 74 | def end(self): | 68 | def end(self): |
| 75 | if _NOT_TTY or IsTrace() or not self._show: | 69 | if _NOT_TTY or IsTrace() or not self._show: |
diff --git a/subcmds/sync.py b/subcmds/sync.py index 47790cc8..0a3cde7d 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -403,8 +403,7 @@ later is required to fix a server side protocol bug. | |||
| 403 | def _Fetch(self, projects, opt, err_event): | 403 | def _Fetch(self, projects, opt, err_event): |
| 404 | fetched = set() | 404 | fetched = set() |
| 405 | lock = _threading.Lock() | 405 | lock = _threading.Lock() |
| 406 | pm = Progress('Fetching projects', len(projects), | 406 | pm = Progress('Fetching projects', len(projects)) |
| 407 | always_print_percentage=opt.quiet) | ||
| 408 | 407 | ||
| 409 | objdir_project_map = dict() | 408 | objdir_project_map = dict() |
| 410 | for project in projects: | 409 | for project in projects: |
