|
|
|
@ -12,16 +12,11 @@ except ImportError:
|
|
|
|
|
pass
|
|
|
|
|
import signal
|
|
|
|
|
|
|
|
|
|
class ProgressBarWidget(object):
|
|
|
|
|
def update(self, pbar):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
class ProgressBarWidgetHFill(object):
|
|
|
|
|
def update(self, pbar, width):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ETA(ProgressBarWidget):
|
|
|
|
|
class ETA(object):
|
|
|
|
|
"Widget for the Estimated Time of Arrival"
|
|
|
|
|
def format_time(self, seconds):
|
|
|
|
|
return time.strftime('%H:%M:%S', time.gmtime(seconds))
|
|
|
|
@ -32,29 +27,10 @@ class ETA(ProgressBarWidget):
|
|
|
|
|
return _('Time').decode('utf-8') + ': %s' \
|
|
|
|
|
%self.format_time(pbar.seconds_elapsed)
|
|
|
|
|
else:
|
|
|
|
|
# elapsed = pbar.seconds_elapsed
|
|
|
|
|
# eta = elapsed * pbar.maxval / pbar.currval - elapsed
|
|
|
|
|
return _('Time').decode('utf-8') + ': %s' \
|
|
|
|
|
%self.format_time(pbar.seconds_elapsed)
|
|
|
|
|
|
|
|
|
|
class FileTransferSpeed(ProgressBarWidget):
|
|
|
|
|
"Widget for showing the transfer speed (useful for file transfers)."
|
|
|
|
|
def __init__(self):
|
|
|
|
|
self.fmt = '%6.2f %s'
|
|
|
|
|
self.units = ['B','K','M','G','T','P']
|
|
|
|
|
def update(self, pbar):
|
|
|
|
|
if pbar.seconds_elapsed < 2e-6:#== 0:
|
|
|
|
|
bps = 0.0
|
|
|
|
|
else:
|
|
|
|
|
bps = float(pbar.currval) / pbar.seconds_elapsed
|
|
|
|
|
spd = bps
|
|
|
|
|
for u in self.units:
|
|
|
|
|
if spd < 1000:
|
|
|
|
|
break
|
|
|
|
|
spd /= 1000
|
|
|
|
|
return self.fmt % (spd, u+'/s')
|
|
|
|
|
|
|
|
|
|
class Percentage(ProgressBarWidget):
|
|
|
|
|
class Percentage(object):
|
|
|
|
|
"Just the percentage done."
|
|
|
|
|
def update(self, pbar):
|
|
|
|
|
return '%3d%%' % pbar.percentage()
|
|
|
|
|