Fix downloading packages form GitHub
@@ -42,10 +42,14 @@ def main(args):
#print("({} bytes)".format(file_size if file_size else "???"))
with open(output_file, 'wb') as f:
+
file_size_dl = 0
block_sz = 8192
+ if file_size == 0:
bar = Bar('Downloading', max=100)
+ else:
+ bar = None
_n = 0
@@ -56,12 +60,14 @@ def main(args):
file_size_dl += len(buf)
f.write(buf)
+ if bar is not None:
n = int(file_size_dl * 100. / file_size)
if n == _n:
continue
_n = n
+
now = monotonic()
dt = now - bar._ts
bar.update_avg(n, dt)
@@ -69,6 +75,7 @@ def main(args):
bar.index = n
bar.update()
+ if bar is not None:
bar.finish()
except Exception as e:
