Permalink
Browse files

Merge remote-tracking branch 'tycho/master' into merge

  • Loading branch information...
2 parents eecbcba + 299a7d1 commit a102e10298dd3722df2a1ecd2d474219d959a070 @mdomsch committed with Dec 6, 2012
Showing with 17 additions and 0 deletions.
  1. +17 −0 S3/Progress.py
View
@@ -5,10 +5,12 @@
import sys
import datetime
+import time
import Utils
class Progress(object):
_stdout = sys.stdout
+ _last_display = 0
def __init__(self, labels, total_size):
self._stdout = sys.stdout
@@ -48,6 +50,13 @@ def output_labels(self):
self._stdout.write(u"%(source)s -> %(destination)s %(extra)s\n" % self.labels)
self._stdout.flush()
+ def _display_needed(self):
+ # We only need to update the display every so often.
+ if time.time() - self._last_display > 1:
+ self._last_display = time.time()
+ return True
+ return False
+
def display(self, new_file = False, done_message = None):
"""
display(new_file = False[/True], done = False[/True])
@@ -98,6 +107,10 @@ def display(self, new_file = False, done_message = None):
self._stdout.flush()
return
+ # Only display progress every so often
+ if not (new_file or done_message) and not self._display_needed():
+ return
+
timedelta = self.time_current - self.time_start
sec_elapsed = timedelta.days * 86400 + timedelta.seconds + float(timedelta.microseconds)/1000000.0
if (sec_elapsed > 0):
@@ -132,6 +145,10 @@ def display(self, new_file = False, done_message = None):
self.output_labels()
return
+ # Only display progress every so often
+ if not (new_file or done_message) and not self._display_needed():
+ return
+
timedelta = self.time_current - self.time_start
sec_elapsed = timedelta.days * 86400 + timedelta.seconds + float(timedelta.microseconds)/1000000.0
if (sec_elapsed > 0):

0 comments on commit a102e10

Please sign in to comment.