Skip to content
Snippets Groups Projects
Commit 53226773 authored by Sebastien Luttringer's avatar Sebastien Luttringer
Browse files

Add a download size information on download progressbar

parent cac33624
No related branches found
No related tags found
No related merge requests found
......@@ -140,6 +140,27 @@ class FileTransferSpeed(Widget):
return self.format % (scaled, self.prefixes[power], self.unit)
class FileTransferSize(Widget):
'Widget for showing the transfer size (useful for file transfers).'
format = '%6.2f %s%s'
prefixes = ' kMGTPEZY'
__slots__ = ('unit', 'format')
def __init__(self, unit='B'):
self.unit = unit
def update(self, pbar):
'Updates the widget with the current SI prefixed speed.'
if pbar.currval < 2e-6: # =~ 0
scaled = power = 0
else:
power = int(math.log(pbar.currval, 1000))
scaled = pbar.currval / 1000.**power
return self.format % (scaled, self.prefixes[power], self.unit)
class AnimatedMarker(Widget):
'''An animated marker for the progress bar which defaults to appear as if
......
......@@ -16,7 +16,8 @@ import time
from subprocess import call, check_call, CalledProcessError
import installsystems
from installsystems.progressbar import ProgressBar, Percentage, FileTransferSpeed
from installsystems.progressbar import ProgressBar, Percentage
from installsystems.progressbar import FileTransferSpeed, FileTransferSize
from installsystems.progressbar import Bar, BouncingBar, ETA, UnknownLength
from installsystems.tarball import Tarball
from installsystems.printer import *
......@@ -72,7 +73,7 @@ class PipeFile(object):
# init progress bar
# we use 0 because a null file is cannot show a progression during write
if self.size == 0:
widget = [ BouncingBar(), " ", FileTransferSpeed() ]
widget = [ FileTransferSize(), " ", BouncingBar(), " ", FileTransferSpeed() ]
maxval = UnknownLength
else:
widget = [ Percentage(), " ", Bar(), " ", FileTransferSpeed(), " ", ETA() ]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment