Reduce number of Downloading prints when the installer output is redirected to a file

This commit is contained in:
Kovid Goyal 2016-03-29 21:08:02 +05:30
parent 7689749f37
commit 9b41e0c98f

View File

@ -228,11 +228,14 @@ class Reporter: # {{{
except ValueError:
prints('Downloading', fname)
self.pb = None
self.last_percent = 0
def __call__(self, blocks, block_size, total_size):
percent = (blocks*block_size)/float(total_size)
if self.pb is None:
prints('Downloaded {0:%}'.format(percent))
if percent - self.last_percent > 0.05:
self.last_percent = percent
prints('Downloaded {0:%}'.format(percent))
else:
try:
self.pb.update(percent)