Skip to content

Commit

Permalink
Merge pull request #37 from mykaul/download_progress
Browse files Browse the repository at this point in the history
Download progress
  • Loading branch information
Yaniv Kaul committed Jan 26, 2016
2 parents 70ab5b4 + 4a09525 commit 0d81d8c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/lago/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,18 @@ def open_url(self, url, suffix='', dest=None):
meta = response.info()
file_size_kb = int(meta.getheaders("Content-Length")[0]) / 1024
if file_size_kb > 0:
sys.stdout.write("Downloading %s Kilobytes from %s \n" %
(file_size_kb, full_url))
sys.stdout.write(
"Downloading %s Kilobytes from %s \n" %
(file_size_kb, full_url)
)

def report(count, block_size, total_size):
percent = (count*block_size*100/float(total_size))
sys.stdout.write("\r% 3.1f%%" % percent + " complete (%d " %
(count*block_size/1024) + "Kilobytes)")
percent = (count * block_size * 100 / float(total_size))
sys.stdout.write(
"\r% 3.1f%%" % percent + " complete (%d " % (
count * block_size / 1024
) + "Kilobytes)"
)
sys.stdout.flush()

if dest:
Expand Down

0 comments on commit 0d81d8c

Please sign in to comment.