Skip to content

Commit

Permalink
Fixed ZeroDivisionError in download summary.
Browse files Browse the repository at this point in the history
Closes #202
  • Loading branch information
jkbrzt committed Feb 18, 2014
1 parent 2c885b0 commit b01906a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion httpie/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,20 @@ def sum_up(self):
time_taken = self.status.time_finished - self.status.time_started

self.output.write(CLEAR_LINE)

try:
speed = actually_downloaded / time_taken
except ZeroDivisionError:
# Either time is 0 (not all systems provide `time.time`
# with a better precision than 1 second), and/or nothing
# has been downloaded.
speed = actually_downloaded

self.output.write(SUMMARY.format(
downloaded=humanize_bytes(actually_downloaded),
total=(self.status.total_size
and humanize_bytes(self.status.total_size)),
speed=humanize_bytes(actually_downloaded / time_taken),
speed=humanize_bytes(speed),
time=time_taken,
))
self.output.flush()

0 comments on commit b01906a

Please sign in to comment.