modified progressbar

develop
Спиридонов Денис 12 years ago
parent a13961691e
commit e4cbb8d573

@ -491,6 +491,8 @@ def get_Progress(client, sid, pid, id):
print print
return return
temp_progress = percent temp_progress = percent
else:
pbar.update(percent)
time.sleep(1) time.sleep(1)
returnProgr = client.service.get_progress(sid, pid, id) returnProgr = client.service.get_progress(sid, pid, id)
percent = returnProgr.percent percent = returnProgr.percent

@ -21,9 +21,7 @@ class ETA(object):
def format_time(self, seconds): def format_time(self, seconds):
return time.strftime('%H:%M:%S', time.gmtime(seconds)) return time.strftime('%H:%M:%S', time.gmtime(seconds))
def update(self, pbar): def update(self, pbar):
if pbar.currval == 0: if pbar.finished:
return _('Time').decode('utf-8') + ': --:--:--'
elif pbar.finished:
return _('Time').decode('utf-8') + ': %s' \ return _('Time').decode('utf-8') + ': %s' \
%self.format_time(pbar.seconds_elapsed) %self.format_time(pbar.seconds_elapsed)
else: else:
@ -111,14 +109,11 @@ class ProgressBar(object):
def _format_line(self): def _format_line(self):
return ''.join(self._format_widgets()).ljust(self.term_width) return ''.join(self._format_widgets()).ljust(self.term_width)
def _need_update(self):
return int(self.percentage()) != int(self.prev_percentage)
def update(self, value): def update(self, value):
"Updates the progress bar to a new value." "Updates the progress bar to a new value."
assert 0 <= value <= self.maxval assert 0 <= value <= self.maxval
self.currval = value self.currval = value
if not self._need_update() or self.finished: if self.finished:
return return
if not self.start_time: if not self.start_time:
self.start_time = time.time() self.start_time = time.time()

Loading…
Cancel
Save