aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2015-11-08 09:38:24 +0900
committerPaul Kehrer <paul.l.kehrer@gmail.com>2015-11-08 09:38:24 +0900
commite0e90a819bcd7bb13f377732ca871068cbf5cd25 (patch)
tree7749d145c1381c8bf42faa021172948bf665debc
parent8d3168b9a64609e9d447b2048ce77a223d377778 (diff)
downloadcryptography-e0e90a819bcd7bb13f377732ca871068cbf5cd25.tar.gz
cryptography-e0e90a819bcd7bb13f377732ca871068cbf5cd25.tar.bz2
cryptography-e0e90a819bcd7bb13f377732ca871068cbf5cd25.zip
add progress bar to wheel downloads
-rw-r--r--dev-requirements.txt1
-rw-r--r--tasks.py19
2 files changed, 18 insertions, 2 deletions
diff --git a/dev-requirements.txt b/dev-requirements.txt
index f6eec132..b33b5e68 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -1,3 +1,4 @@
+clint
coverage
flake8
flake8-import-order
diff --git a/tasks.py b/tasks.py
index 76d0d029..15027d74 100644
--- a/tasks.py
+++ b/tasks.py
@@ -8,6 +8,8 @@ import getpass
import os
import time
+from clint.textui.progress import Bar as ProgressBar
+
import invoke
import requests
@@ -66,15 +68,28 @@ def download_artifacts(session):
response.raise_for_status()
for artifact in response.json()["artifacts"]:
response = session.get(
- "{0}artifact/{1}".format(run["url"], artifact["relativePath"])
+ "{0}artifact/{1}".format(run["url"], artifact["relativePath"]),
+ stream=True
+ )
+ assert response.headers["content-length"]
+ print("Downloading {0}".format(artifact["fileName"]))
+ bar = ProgressBar(
+ expected_size=int(response.headers["content-length"]),
+ filled_char="="
)
+ content = b''
+ for data in response.iter_content(chunk_size=8192):
+ content += data
+ bar.show(len(content))
+ if bar.expected_size == len(content):
+ bar.done()
out_path = os.path.join(
os.path.dirname(__file__),
"dist",
artifact["fileName"],
)
with open(out_path, "wb") as f:
- f.write(response.content)
+ f.write(content)
paths.append(out_path)
return paths