aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2014-09-26 23:30:31 -0400
committerAlex Gaynor <alex.gaynor@gmail.com>2014-09-26 23:30:31 -0400
commit9ca7f036907d6b08a4b06c8fb22bbc6989f84416 (patch)
tree6cf72d973b14c4f0804f03d38e310fe67e585ed4
parent45d4c5909bd857986b901d59fd4d77bce63bfeff (diff)
downloadcryptography-9ca7f036907d6b08a4b06c8fb22bbc6989f84416.tar.gz
cryptography-9ca7f036907d6b08a4b06c8fb22bbc6989f84416.tar.bz2
cryptography-9ca7f036907d6b08a4b06c8fb22bbc6989f84416.zip
Refs #1224 -- try to purge PyPI after new tarball is uploaded
Also reuse an HTTP connection for stuff
-rw-r--r--tasks.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/tasks.py b/tasks.py
index c9fdfa99..5733cc4e 100644
--- a/tasks.py
+++ b/tasks.py
@@ -25,9 +25,9 @@ import requests
JENKINS_URL = "https://jenkins.cryptography.io/job/cryptography-wheel-builder"
-def wait_for_build_completed():
+def wait_for_build_completed(session):
while True:
- response = requests.get(
+ response = session.get(
"{0}/lastBuild/api/json/".format(JENKINS_URL),
headers={
"Accept": "application/json",
@@ -40,8 +40,8 @@ def wait_for_build_completed():
time.sleep(0.1)
-def download_artifacts():
- response = requests.get(
+def download_artifacts(session):
+ response = session.get(
"{0}/lastBuild/api/json/".format(JENKINS_URL),
headers={
"Accept": "application/json"
@@ -54,7 +54,7 @@ def download_artifacts():
paths = []
for run in response.json()["runs"]:
- response = requests.get(
+ response = session.get(
run["url"] + "api/json/",
headers={
"Accept": "application/json",
@@ -62,7 +62,7 @@ def download_artifacts():
)
response.raise_for_status()
for artifact in response.json()["artifacts"]:
- response = requests.get(
+ response = session.get(
"{0}artifact/{1}".format(run["url"], artifact["relativePath"])
)
out_path = os.path.join(
@@ -92,9 +92,14 @@ def release(version):
"vectors/dist/cryptography_vectors-{0}*".format(version)
)
+ session = requests.Session()
+
+ response = session.request("PURGE", "https://pypi.python.org/simple/cryptography/")
+ response.raise_for_status()
+
username = getpass.getpass("Input the GitHub/Jenkins username: ")
token = getpass.getpass("Input the Jenkins token: ")
- response = requests.post(
+ response = session.post(
"{0}/build".format(JENKINS_URL),
auth=requests.auth.HTTPBasicAuth(
username, token
@@ -104,6 +109,6 @@ def release(version):
}
)
response.raise_for_status()
- wait_for_build_completed()
- paths = download_artifacts()
+ wait_for_build_completed(session)
+ paths = download_artifacts(session)
invoke.run("twine upload {0}".format(" ".join(paths)))