report_progress() shouldn't fail w/o total_bytes

In the absence of the total_bytes key, just say "Completed" (looks
better than a bare "100%").

Compose the msg_template additively.

In practice, for pipes (where we lack total bytes) we also lack
elapsed time, so we end up with:
  [download] Completed
though if elapsed time were somehow set we'd have:
  [download] Completed in 00:10
This commit is contained in:
John Hawkinson 2016-10-09 10:36:40 -04:00
parent cb1cea4b34
commit 5a1e040b8e

View File

@ -242,12 +242,14 @@ class FileDownloader(object):
if self.params.get('noprogress', False):
self.to_screen('[download] Download completed')
else:
s['_total_bytes_str'] = format_bytes(s['total_bytes'])
if s.get('total_bytes') is not None:
s['_total_bytes_str'] = format_bytes(s['total_bytes'])
msg_template = '100%% of %(_total_bytes_str)s'
else:
msg_template = 'Completed'
if s.get('elapsed') is not None:
s['_elapsed_str'] = self.format_seconds(s['elapsed'])
msg_template = '100%% of %(_total_bytes_str)s in %(_elapsed_str)s'
else:
msg_template = '100%% of %(_total_bytes_str)s'
msg_template += ' in %(_elapsed_str)s'
self._report_progress_status(
msg_template % s, is_last_line=True)