* fix: use keyword args properly in display_progress, however this is
still flaky. ui implementors please note that this will be replaced by a proper "progress object" implementation, allowing update of a specified progress object. * fix: after the thing is presumably complete print complete and newline * workaround: don't do display progress twice with 100%, that seems mistaken anyway, the percent should be rounded down, not up.
This commit is contained in:
@@ -113,10 +113,12 @@ class CLI(UI):
|
||||
|
||||
return False
|
||||
|
||||
def display_progress(self, pd):
|
||||
def display_progress(self, **ka):
|
||||
out = '\r%-30.30s %3d%% %12.2f %s' % \
|
||||
(pd['filename'], pd['percent'], pd['rate'], pd['symbol'])
|
||||
(ka['filename'], ka['percent'], ka['rate'], ka['symbol'])
|
||||
self.output(out)
|
||||
if ka['percent'] == 100:
|
||||
self.output(colorize(' [complete]\n', 'gray'))
|
||||
|
||||
def status(self, msg = None):
|
||||
if msg:
|
||||
|
||||
+8
-5
@@ -98,6 +98,7 @@ class Fetcher:
|
||||
if self.progress:
|
||||
p = self.progress(totalsize, existsize)
|
||||
self.percent = p.update(size)
|
||||
self.complete = False
|
||||
while chunk:
|
||||
dest.write(chunk)
|
||||
chunk = fileURI.read(bs)
|
||||
@@ -113,11 +114,13 @@ class Fetcher:
|
||||
if self.progress:
|
||||
if p.update(size):
|
||||
self.percent = p.percent
|
||||
retval = {'filename': self.url.filename(),
|
||||
'percent' : self.percent,
|
||||
'rate': self.rate,
|
||||
'symbol': symbol}
|
||||
ctx.ui.display_progress(retval)
|
||||
if not self.complete:
|
||||
ctx.ui.display_progress(filename = self.url.filename(),
|
||||
percent = self.percent,
|
||||
rate = self.rate,
|
||||
symbol = symbol)
|
||||
if self.percent == 100: #FIXME: will be superseded by a
|
||||
self.complete = True # working progress interface
|
||||
|
||||
dest.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user