* 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
|
return False
|
||||||
|
|
||||||
def display_progress(self, pd):
|
def display_progress(self, **ka):
|
||||||
out = '\r%-30.30s %3d%% %12.2f %s' % \
|
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)
|
self.output(out)
|
||||||
|
if ka['percent'] == 100:
|
||||||
|
self.output(colorize(' [complete]\n', 'gray'))
|
||||||
|
|
||||||
def status(self, msg = None):
|
def status(self, msg = None):
|
||||||
if msg:
|
if msg:
|
||||||
|
|||||||
+8
-5
@@ -98,6 +98,7 @@ class Fetcher:
|
|||||||
if self.progress:
|
if self.progress:
|
||||||
p = self.progress(totalsize, existsize)
|
p = self.progress(totalsize, existsize)
|
||||||
self.percent = p.update(size)
|
self.percent = p.update(size)
|
||||||
|
self.complete = False
|
||||||
while chunk:
|
while chunk:
|
||||||
dest.write(chunk)
|
dest.write(chunk)
|
||||||
chunk = fileURI.read(bs)
|
chunk = fileURI.read(bs)
|
||||||
@@ -113,11 +114,13 @@ class Fetcher:
|
|||||||
if self.progress:
|
if self.progress:
|
||||||
if p.update(size):
|
if p.update(size):
|
||||||
self.percent = p.percent
|
self.percent = p.percent
|
||||||
retval = {'filename': self.url.filename(),
|
if not self.complete:
|
||||||
'percent' : self.percent,
|
ctx.ui.display_progress(filename = self.url.filename(),
|
||||||
'rate': self.rate,
|
percent = self.percent,
|
||||||
'symbol': symbol}
|
rate = self.rate,
|
||||||
ctx.ui.display_progress(retval)
|
symbol = symbol)
|
||||||
|
if self.percent == 100: #FIXME: will be superseded by a
|
||||||
|
self.complete = True # working progress interface
|
||||||
|
|
||||||
dest.close()
|
dest.close()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user