summaryrefslogtreecommitdiffstats
path: root/progress.py
diff options
context:
space:
mode:
authorTim Schumacher <timschumi2@arcor.de>2017-06-28 18:29:23 +0200
committerTim Schumacher <timschumi2@arcor.de>2017-07-15 16:44:55 +0000
commit7be072efa6522a94ee0bab16539a442cc4713d65 (patch)
tree96c5577a829b6df2e7b2fd5f6ea35e7ba6177a26 /progress.py
parent224a31a765eb943443640301a715d2d4eb005b79 (diff)
downloadgit-repo-7be072efa6522a94ee0bab16539a442cc4713d65.tar.gz
Always print percentage when syncing quietly
Change-Id: I574396e63520781067ed1e991c41caf7640e5731
Diffstat (limited to 'progress.py')
-rw-r--r--progress.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/progress.py b/progress.py
index b08f52e5..0dd5d1a8 100644
--- a/progress.py
+++ b/progress.py
@@ -21,7 +21,8 @@ from trace import IsTrace
21_NOT_TTY = not os.isatty(2) 21_NOT_TTY = not os.isatty(2)
22 22
23class Progress(object): 23class Progress(object):
24 def __init__(self, title, total=0, units='', print_newline=False): 24 def __init__(self, title, total=0, units='', print_newline=False,
25 always_print_percentage=False):
25 self._title = title 26 self._title = title
26 self._total = total 27 self._total = total
27 self._done = 0 28 self._done = 0
@@ -30,6 +31,7 @@ class Progress(object):
30 self._show = False 31 self._show = False
31 self._units = units 32 self._units = units
32 self._print_newline = print_newline 33 self._print_newline = print_newline
34 self._always_print_percentage = always_print_percentage
33 35
34 def update(self, inc=1): 36 def update(self, inc=1):
35 self._done += inc 37 self._done += inc
@@ -51,7 +53,7 @@ class Progress(object):
51 else: 53 else:
52 p = (100 * self._done) / self._total 54 p = (100 * self._done) / self._total
53 55
54 if self._lastp != p: 56 if self._lastp != p or self._always_print_percentage:
55 self._lastp = p 57 self._lastp = p
56 sys.stderr.write('\r%s: %3d%% (%d%s/%d%s)%s' % ( 58 sys.stderr.write('\r%s: %3d%% (%d%s/%d%s)%s' % (
57 self._title, 59 self._title,