summaryrefslogtreecommitdiffstats
path: root/progress.py
diff options
context:
space:
mode:
Diffstat (limited to 'progress.py')
-rw-r--r--progress.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/progress.py b/progress.py
index 98bb6429..b119b374 100644
--- a/progress.py
+++ b/progress.py
@@ -14,6 +14,7 @@
14# limitations under the License. 14# limitations under the License.
15 15
16import sys 16import sys
17from time import time
17from trace import IsTrace 18from trace import IsTrace
18 19
19class Progress(object): 20class Progress(object):
@@ -22,6 +23,8 @@ class Progress(object):
22 self._total = total 23 self._total = total
23 self._done = 0 24 self._done = 0
24 self._lastp = -1 25 self._lastp = -1
26 self._start = time()
27 self._show = False
25 28
26 def update(self, inc=1): 29 def update(self, inc=1):
27 self._done += inc 30 self._done += inc
@@ -29,6 +32,12 @@ class Progress(object):
29 if IsTrace(): 32 if IsTrace():
30 return 33 return
31 34
35 if not self._show:
36 if 0.5 <= time() - self._start:
37 self._show = True
38 else:
39 return
40
32 if self._total <= 0: 41 if self._total <= 0:
33 sys.stderr.write('\r%s: %d, ' % ( 42 sys.stderr.write('\r%s: %d, ' % (
34 self._title, 43 self._title,
@@ -47,7 +56,7 @@ class Progress(object):
47 sys.stderr.flush() 56 sys.stderr.flush()
48 57
49 def end(self): 58 def end(self):
50 if IsTrace(): 59 if IsTrace() or not self._show:
51 return 60 return
52 61
53 if self._total <= 0: 62 if self._total <= 0: