prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Update release automation for new wheel builder
  Once #3636 is merged we need to update the release automation to trigger the new wheel builder and download the artifacts.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `release.py`
  Content:
  ```
  1 # This file is dual licensed under the terms of the Apache License, Version
  2 # 2.0, and the BSD License. See the LICENSE file in the root of this repository
  3 # for complete details.
  4 
  5 from __future__ import absolute_import, division, print_function
  6 
  7 import getpass
  8 import io
  9 import os
  10 import subprocess
  11 import time
  12 
  13 import click
  14 
  15 from clint.textui.progress import Bar as ProgressBar
  16 
  17 import requests
  18 
  19 
  20 JENKINS_URL = "https://jenkins.cryptography.io/job/cryptography-wheel-builder"
  21 
  22 
  23 def run(*args, **kwargs):
  24     kwargs.setdefault("stderr", subprocess.STDOUT)
  25     subprocess.check_output(list(args), **kwargs)
  26 
  27 
  28 def wait_for_build_completed(session):
  29     # Wait 20 seconds before actually checking if the build is complete, to
  30     # ensure that it had time to really start.
  31     time.sleep(20)
  32     while True:
  33         response = session.get(
  34             "{0}/lastBuild/api/json/".format(JENKINS_URL),
  35             headers={
  36                 "Accept": "application/json",
  37             }
  38         )
  39         response.raise_for_status()
  40         if not response.json()["building"]:
  41             assert response.json()["result"] == "SUCCESS"
  42             break
  43         time.sleep(0.1)
  44 
  45 
  46 def download_artifacts(session):
  47     response = session.get(
  48         "{0}/lastBuild/api/json/".format(JENKINS_URL),
  49         headers={
  50             "Accept": "application/json"
  51         }
  52     )
  53     response.raise_for_status()
  54     assert not response.json()["building"]
  55     assert response.json()["result"] == "SUCCESS"
  56 
  57     paths = []
  58 
  59     last_build_number = response.json()["number"]
  60     for run in response.json()["runs"]:
  61         if run["number"] != last_build_number:
  62             print(
  63                 "Skipping {0} as it is not from the latest build ({1})".format(
  64                     run["url"], last_build_number
  65                 )
  66             )
  67             continue
  68 
  69         response = session.get(
  70             run["url"] + "api/json/",
  71             headers={
  72                 "Accept": "application/json",
  73             }
  74         )
  75         response.raise_for_status()
  76         for artifact in response.json()["artifacts"]:
  77             response = session.get(
  78                 "{0}artifact/{1}".format(run["url"], artifact["relativePath"]),
  79                 stream=True
  80             )
  81             assert response.headers["content-length"]
  82             print("Downloading {0}".format(artifact["fileName"]))
  83             bar = ProgressBar(
  84                 expected_size=int(response.headers["content-length"]),
  85                 filled_char="="
  86             )
  87             content = io.BytesIO()
  88             for data in response.iter_content(chunk_size=8192):
  89                 content.write(data)
  90                 bar.show(content.tell())
  91             assert bar.expected_size == content.tell()
  92             bar.done()
  93             out_path = os.path.join(
  94                 os.path.dirname(__file__),
  95                 "dist",
  96                 artifact["fileName"],
  97             )
  98             with open(out_path, "wb") as f:
  99                 f.write(content.getvalue())
  100             paths.append(out_path)
  101     return paths
  102 
  103 
  104 @click.command()
  105 @click.argument("version")
  106 def release(version):
  107     """
  108     ``version`` should be a string like '0.4' or '1.0'.
  109     """
  110     run("git", "tag", "-s", version, "-m", "{0} release".format(version))
  111     run("git", "push", "--tags")
  112 
  113     run("python", "setup.py", "sdist")
  114     run("python", "setup.py", "sdist", "bdist_wheel", cwd="vectors/")
  115 
  116     run(
  117         "twine", "upload", "-s", "dist/cryptography-{0}*".format(version),
  118         "vectors/dist/cryptography_vectors-{0}*".format(version), shell=True
  119     )
  120 
  121     session = requests.Session()
  122 
  123     # This tells the CDN to delete the cached response for the URL. We do this
  124     # so that the Jenkins builders will see the new sdist immediately when they
  125     # go to build the wheels.
  126     response = session.request(
  127         "PURGE", "https://pypi.python.org/simple/cryptography/"
  128     )
  129     response.raise_for_status()
  130 
  131     username = getpass.getpass("Input the GitHub/Jenkins username: ")
  132     token = getpass.getpass("Input the Jenkins token: ")
  133     response = session.post(
  134         "{0}/build".format(JENKINS_URL),
  135         auth=requests.auth.HTTPBasicAuth(
  136             username, token
  137         ),
  138         params={
  139             "cause": "Building wheels for {0}".format(version)
  140         }
  141     )
  142     response.raise_for_status()
  143     wait_for_build_completed(session)
  144     paths = download_artifacts(session)
  145     run("twine", "upload", " ".join(paths))
  146 
  147 
  148 if __name__ == "__main__":
  149     release()
  150
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/release.py b/release.py
  --- a/release.py
  +++ b/release.py
  @@ -17,7 +17,10 @@
   import requests
   
   
  -JENKINS_URL = "https://jenkins.cryptography.io/job/cryptography-wheel-builder"
  +JENKINS_URL = (
  +    "https://ci.cryptography.io/job/cryptography-support-jobs/"
  +    "job/wheel-builder"
  +)
   
   
   def run(*args, **kwargs):
  @@ -128,14 +131,11 @@
       )
       response.raise_for_status()
   
  -    username = getpass.getpass("Input the GitHub/Jenkins username: ")
       token = getpass.getpass("Input the Jenkins token: ")
  -    response = session.post(
  +    response = session.get(
           "{0}/build".format(JENKINS_URL),
  -        auth=requests.auth.HTTPBasicAuth(
  -            username, token
  -        ),
           params={
  +            "token": token,
               "cause": "Building wheels for {0}".format(version)
           }
       )
  
verification_info: {"golden_diff": "diff --git a/release.py b/release.py\n--- a/release.py\n+++ b/release.py\n@@ -17,7 +17,10 @@\n import requests\n \n \n-JENKINS_URL = \"https://jenkins.cryptography.io/job/cryptography-wheel-builder\"\n+JENKINS_URL = (\n+    \"https://ci.cryptography.io/job/cryptography-support-jobs/\"\n+    \"job/wheel-builder\"\n+)\n \n \n def run(*args, **kwargs):\n@@ -128,14 +131,11 @@\n     )\n     response.raise_for_status()\n \n-    username = getpass.getpass(\"Input the GitHub/Jenkins username: \")\n     token = getpass.getpass(\"Input the Jenkins token: \")\n-    response = session.post(\n+    response = session.get(\n         \"{0}/build\".format(JENKINS_URL),\n-        auth=requests.auth.HTTPBasicAuth(\n-            username, token\n-        ),\n         params={\n+            \"token\": token,\n             \"cause\": \"Building wheels for {0}\".format(version)\n         }\n     )\n", "issue": "Update release automation for new wheel builder\nOnce #3636 is merged we need to update the release automation to trigger the new wheel builder and download the artifacts.\n", "before_files": [{"content": "# This file is dual licensed under the terms of the Apache License, Version\n# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n# for complete details.\n\nfrom __future__ import absolute_import, division, print_function\n\nimport getpass\nimport io\nimport os\nimport subprocess\nimport time\n\nimport click\n\nfrom clint.textui.progress import Bar as ProgressBar\n\nimport requests\n\n\nJENKINS_URL = \"https://jenkins.cryptography.io/job/cryptography-wheel-builder\"\n\n\ndef run(*args, **kwargs):\n    kwargs.setdefault(\"stderr\", subprocess.STDOUT)\n    subprocess.check_output(list(args), **kwargs)\n\n\ndef wait_for_build_completed(session):\n    # Wait 20 seconds before actually checking if the build is complete, to\n    # ensure that it had time to really start.\n    time.sleep(20)\n    while True:\n        response = session.get(\n            \"{0}/lastBuild/api/json/\".format(JENKINS_URL),\n            headers={\n                \"Accept\": \"application/json\",\n            }\n        )\n        response.raise_for_status()\n        if not response.json()[\"building\"]:\n            assert response.json()[\"result\"] == \"SUCCESS\"\n            break\n        time.sleep(0.1)\n\n\ndef download_artifacts(session):\n    response = session.get(\n        \"{0}/lastBuild/api/json/\".format(JENKINS_URL),\n        headers={\n            \"Accept\": \"application/json\"\n        }\n    )\n    response.raise_for_status()\n    assert not response.json()[\"building\"]\n    assert response.json()[\"result\"] == \"SUCCESS\"\n\n    paths = []\n\n    last_build_number = response.json()[\"number\"]\n    for run in response.json()[\"runs\"]:\n        if run[\"number\"] != last_build_number:\n            print(\n                \"Skipping {0} as it is not from the latest build ({1})\".format(\n                    run[\"url\"], last_build_number\n                )\n            )\n            continue\n\n        response = session.get(\n            run[\"url\"] + \"api/json/\",\n            headers={\n                \"Accept\": \"application/json\",\n            }\n        )\n        response.raise_for_status()\n        for artifact in response.json()[\"artifacts\"]:\n            response = session.get(\n                \"{0}artifact/{1}\".format(run[\"url\"], artifact[\"relativePath\"]),\n                stream=True\n            )\n            assert response.headers[\"content-length\"]\n            print(\"Downloading {0}\".format(artifact[\"fileName\"]))\n            bar = ProgressBar(\n                expected_size=int(response.headers[\"content-length\"]),\n                filled_char=\"=\"\n            )\n            content = io.BytesIO()\n            for data in response.iter_content(chunk_size=8192):\n                content.write(data)\n                bar.show(content.tell())\n            assert bar.expected_size == content.tell()\n            bar.done()\n            out_path = os.path.join(\n                os.path.dirname(__file__),\n                \"dist\",\n                artifact[\"fileName\"],\n            )\n            with open(out_path, \"wb\") as f:\n                f.write(content.getvalue())\n            paths.append(out_path)\n    return paths\n\n\n@click.command()\n@click.argument(\"version\")\ndef release(version):\n    \"\"\"\n    ``version`` should be a string like '0.4' or '1.0'.\n    \"\"\"\n    run(\"git\", \"tag\", \"-s\", version, \"-m\", \"{0} release\".format(version))\n    run(\"git\", \"push\", \"--tags\")\n\n    run(\"python\", \"setup.py\", \"sdist\")\n    run(\"python\", \"setup.py\", \"sdist\", \"bdist_wheel\", cwd=\"vectors/\")\n\n    run(\n        \"twine\", \"upload\", \"-s\", \"dist/cryptography-{0}*\".format(version),\n        \"vectors/dist/cryptography_vectors-{0}*\".format(version), shell=True\n    )\n\n    session = requests.Session()\n\n    # This tells the CDN to delete the cached response for the URL. We do this\n    # so that the Jenkins builders will see the new sdist immediately when they\n    # go to build the wheels.\n    response = session.request(\n        \"PURGE\", \"https://pypi.python.org/simple/cryptography/\"\n    )\n    response.raise_for_status()\n\n    username = getpass.getpass(\"Input the GitHub/Jenkins username: \")\n    token = getpass.getpass(\"Input the Jenkins token: \")\n    response = session.post(\n        \"{0}/build\".format(JENKINS_URL),\n        auth=requests.auth.HTTPBasicAuth(\n            username, token\n        ),\n        params={\n            \"cause\": \"Building wheels for {0}\".format(version)\n        }\n    )\n    response.raise_for_status()\n    wait_for_build_completed(session)\n    paths = download_artifacts(session)\n    run(\"twine\", \"upload\", \" \".join(paths))\n\n\nif __name__ == \"__main__\":\n    release()\n", "path": "release.py"}], "after_files": [{"content": "# This file is dual licensed under the terms of the Apache License, Version\n# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n# for complete details.\n\nfrom __future__ import absolute_import, division, print_function\n\nimport getpass\nimport io\nimport os\nimport subprocess\nimport time\n\nimport click\n\nfrom clint.textui.progress import Bar as ProgressBar\n\nimport requests\n\n\nJENKINS_URL = (\n    \"https://ci.cryptography.io/job/cryptography-support-jobs/\"\n    \"job/wheel-builder\"\n)\n\n\ndef run(*args, **kwargs):\n    kwargs.setdefault(\"stderr\", subprocess.STDOUT)\n    subprocess.check_output(list(args), **kwargs)\n\n\ndef wait_for_build_completed(session):\n    # Wait 20 seconds before actually checking if the build is complete, to\n    # ensure that it had time to really start.\n    time.sleep(20)\n    while True:\n        response = session.get(\n            \"{0}/lastBuild/api/json/\".format(JENKINS_URL),\n            headers={\n                \"Accept\": \"application/json\",\n            }\n        )\n        response.raise_for_status()\n        if not response.json()[\"building\"]:\n            assert response.json()[\"result\"] == \"SUCCESS\"\n            break\n        time.sleep(0.1)\n\n\ndef download_artifacts(session):\n    response = session.get(\n        \"{0}/lastBuild/api/json/\".format(JENKINS_URL),\n        headers={\n            \"Accept\": \"application/json\"\n        }\n    )\n    response.raise_for_status()\n    assert not response.json()[\"building\"]\n    assert response.json()[\"result\"] == \"SUCCESS\"\n\n    paths = []\n\n    last_build_number = response.json()[\"number\"]\n    for run in response.json()[\"runs\"]:\n        if run[\"number\"] != last_build_number:\n            print(\n                \"Skipping {0} as it is not from the latest build ({1})\".format(\n                    run[\"url\"], last_build_number\n                )\n            )\n            continue\n\n        response = session.get(\n            run[\"url\"] + \"api/json/\",\n            headers={\n                \"Accept\": \"application/json\",\n            }\n        )\n        response.raise_for_status()\n        for artifact in response.json()[\"artifacts\"]:\n            response = session.get(\n                \"{0}artifact/{1}\".format(run[\"url\"], artifact[\"relativePath\"]),\n                stream=True\n            )\n            assert response.headers[\"content-length\"]\n            print(\"Downloading {0}\".format(artifact[\"fileName\"]))\n            bar = ProgressBar(\n                expected_size=int(response.headers[\"content-length\"]),\n                filled_char=\"=\"\n            )\n            content = io.BytesIO()\n            for data in response.iter_content(chunk_size=8192):\n                content.write(data)\n                bar.show(content.tell())\n            assert bar.expected_size == content.tell()\n            bar.done()\n            out_path = os.path.join(\n                os.path.dirname(__file__),\n                \"dist\",\n                artifact[\"fileName\"],\n            )\n            with open(out_path, \"wb\") as f:\n                f.write(content.getvalue())\n            paths.append(out_path)\n    return paths\n\n\n@click.command()\n@click.argument(\"version\")\ndef release(version):\n    \"\"\"\n    ``version`` should be a string like '0.4' or '1.0'.\n    \"\"\"\n    run(\"git\", \"tag\", \"-s\", version, \"-m\", \"{0} release\".format(version))\n    run(\"git\", \"push\", \"--tags\")\n\n    run(\"python\", \"setup.py\", \"sdist\")\n    run(\"python\", \"setup.py\", \"sdist\", \"bdist_wheel\", cwd=\"vectors/\")\n\n    run(\n        \"twine\", \"upload\", \"-s\", \"dist/cryptography-{0}*\".format(version),\n        \"vectors/dist/cryptography_vectors-{0}*\".format(version), shell=True\n    )\n\n    session = requests.Session()\n\n    # This tells the CDN to delete the cached response for the URL. We do this\n    # so that the Jenkins builders will see the new sdist immediately when they\n    # go to build the wheels.\n    response = session.request(\n        \"PURGE\", \"https://pypi.python.org/simple/cryptography/\"\n    )\n    response.raise_for_status()\n\n    token = getpass.getpass(\"Input the Jenkins token: \")\n    response = session.get(\n        \"{0}/build\".format(JENKINS_URL),\n        params={\n            \"token\": token,\n            \"cause\": \"Building wheels for {0}\".format(version)\n        }\n    )\n    response.raise_for_status()\n    wait_for_build_completed(session)\n    paths = download_artifacts(session)\n    run(\"twine\", \"upload\", \" \".join(paths))\n\n\nif __name__ == \"__main__\":\n    release()\n", "path": "release.py"}]}