diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2017-05-29 22:23:56 -0500 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2017-05-29 23:23:56 -0400 |
commit | 1d08e5104a441eb8d13baaac832dad3174f1ec9f (patch) | |
tree | 29076c8945eff79ccd6aadee6a807364777769af | |
parent | b90e8d81a3814331fafc732fa0f2d44f5f71dfbb (diff) | |
download | cryptography-1d08e5104a441eb8d13baaac832dad3174f1ec9f.tar.gz cryptography-1d08e5104a441eb8d13baaac832dad3174f1ec9f.tar.bz2 cryptography-1d08e5104a441eb8d13baaac832dad3174f1ec9f.zip |
download artifacts from new jenkins (#3645)
turns out new jenkins changed its JSON a bit.
-rw-r--r-- | release.py | 69 |
1 files changed, 27 insertions, 42 deletions
@@ -54,53 +54,38 @@ def download_artifacts(session): } ) response.raise_for_status() - assert not response.json()["building"] - assert response.json()["result"] == "SUCCESS" + json_response = response.json() + assert not json_response["building"] + assert json_response["result"] == "SUCCESS" paths = [] - last_build_number = response.json()["number"] - for run in response.json()["runs"]: - if run["number"] != last_build_number: - print( - "Skipping {0} as it is not from the latest build ({1})".format( - run["url"], last_build_number - ) - ) - continue - + for artifact in json_response["artifacts"]: response = session.get( - run["url"] + "api/json/", - headers={ - "Accept": "application/json", - } + "{0}artifact/{1}".format( + json_response["url"], artifact["relativePath"] + ), stream=True ) - response.raise_for_status() - for artifact in response.json()["artifacts"]: - response = session.get( - "{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(content.getvalue()) - paths.append(out_path) + 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(content.getvalue()) + paths.append(out_path) return paths |