aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2015-11-07 21:39:31 -0500
committerAlex Gaynor <alex.gaynor@gmail.com>2015-11-07 21:39:31 -0500
commitb91a2448c668f42f7d18489dcd71ab02de7112ca (patch)
tree48d98bc3d1488ab075a67940c2af263244ed6d4c
parent8d3168b9a64609e9d447b2048ce77a223d377778 (diff)
parentff0d3754fa57db75ce94c375fbbbdeea7c0d7635 (diff)
downloadcryptography-b91a2448c668f42f7d18489dcd71ab02de7112ca.tar.gz
cryptography-b91a2448c668f42f7d18489dcd71ab02de7112ca.tar.bz2
cryptography-b91a2448c668f42f7d18489dcd71ab02de7112ca.zip
Merge pull request #2469 from reaperhulk/progress-bars
add progress bar to wheel downloads
-rw-r--r--dev-requirements.txt1
-rw-r--r--tasks.py20
2 files changed, 19 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..2051093e 100644
--- a/tasks.py
+++ b/tasks.py
@@ -5,9 +5,12 @@
from __future__ import absolute_import, division, print_function
import getpass
+import io
import os
import time
+from clint.textui.progress import Bar as ProgressBar
+
import invoke
import requests
@@ -66,15 +69,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 = io.BytesIO()
+ for data in response.iter_content(chunk_size=8192):
+ content.write(data)
+ bar.show(content.tell())
+ assert bar.expected_size == content.tell()
+ 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.getvalue())
paths.append(out_path)
return paths