Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add a basic progress meter for when progressbar isn't available.

  • Loading branch information...
commit 2369f3b31c75c09a5d63bff814e24a1535d7c61a 1 parent 8be0057
@jasonish authored
Showing with 17 additions and 1 deletion.
  1. +17 −1 lib/ruledownloader/ruledownloader.py
View
18 lib/ruledownloader/ruledownloader.py
@@ -59,6 +59,22 @@ def update(self, transferred, block_size, total_size):
def done(self):
pass
+class SimpleProgressMeter(object):
+
+ def __init__(self):
+ self.width = 9
+
+ def update(self, transferred, block_size, total_size):
+ val = int((transferred * block_size) / float(total_size) * 100)
+ sys.stdout.write("\b" * (self.width + 1))
+ format = "%%%ds%%%%" % (self.width)
+ sys.stdout.write(format % (val))
+ sys.stdout.flush()
+
+ def done(self):
+ sys.stdout.write("\n")
+ sys.stdout.flush()
+
class FancyProgressMeter(object):
def __init__(self):
@@ -81,7 +97,7 @@ def get_progress_meter():
elif has_progressbar:
return FancyProgressMeter()
else:
- return NullProgressMeter()
+ return SimpleProgressMeter()
def getFileMd5(filename):
""" Return the hex md5 of the given filename. """
Please sign in to comment.
Something went wrong with that request. Please try again.