Fix the report progress when file_size is unknown (#1731)
The report_progress function will accept eta and percent with None value and will set the message to 'Unknow ETA' or 'Unknown %'. Otherwise the values must be numbers.
This commit is contained in:
parent
b1a80ec1a9
commit
4ac5306ae7
@ -234,8 +234,14 @@ class FileDownloader(object):
|
|||||||
if self.params.get('noprogress', False):
|
if self.params.get('noprogress', False):
|
||||||
return
|
return
|
||||||
clear_line = (u'\x1b[K' if sys.stderr.isatty() and os.name != 'nt' else u'')
|
clear_line = (u'\x1b[K' if sys.stderr.isatty() and os.name != 'nt' else u'')
|
||||||
|
if eta is not None:
|
||||||
eta_str = self.format_eta(eta)
|
eta_str = self.format_eta(eta)
|
||||||
|
else:
|
||||||
|
eta_str = 'Unknown ETA'
|
||||||
|
if percent is not None:
|
||||||
percent_str = self.format_percent(percent)
|
percent_str = self.format_percent(percent)
|
||||||
|
else:
|
||||||
|
percent_str = 'Unknown %'
|
||||||
speed_str = self.format_speed(speed)
|
speed_str = self.format_speed(speed)
|
||||||
if self.params.get('progress_with_newline', False):
|
if self.params.get('progress_with_newline', False):
|
||||||
self.to_screen(u'[download] %s of %s at %s ETA %s' %
|
self.to_screen(u'[download] %s of %s at %s ETA %s' %
|
||||||
@ -557,8 +563,7 @@ class FileDownloader(object):
|
|||||||
# Progress message
|
# Progress message
|
||||||
speed = self.calc_speed(start, time.time(), byte_counter - resume_len)
|
speed = self.calc_speed(start, time.time(), byte_counter - resume_len)
|
||||||
if data_len is None:
|
if data_len is None:
|
||||||
self.report_progress('Unknown %', data_len_str, speed, 'Unknown ETA')
|
eta = percent = None
|
||||||
eta = None
|
|
||||||
else:
|
else:
|
||||||
percent = self.calc_percent(byte_counter, data_len)
|
percent = self.calc_percent(byte_counter, data_len)
|
||||||
eta = self.calc_eta(start, time.time(), data_len - resume_len, byte_counter - resume_len)
|
eta = self.calc_eta(start, time.time(), data_len - resume_len, byte_counter - resume_len)
|
||||||
|
Loading…
Reference in New Issue
Block a user