diff --git a/plugins/python-build/scripts/add_cpython.py b/plugins/python-build/scripts/add_cpython.py index 3d9a3d1d..77c1dfe9 100755 --- a/plugins/python-build/scripts/add_cpython.py +++ b/plugins/python-build/scripts/add_cpython.py @@ -33,6 +33,13 @@ import tqdm logger = logging.getLogger(__name__) + +def _fetch(url: str) -> requests.Response: + response = requests.get(url, timeout=30) + response.raise_for_status() + return response + + CUTOFF_VERSION=packaging.version.Version('3.10') EXCLUDED_VERSIONS= { } @@ -542,8 +549,7 @@ class OpenSSLVersionsDirectory(KeyedList[_OpenSSLVersionInfo, packaging.version. url = "https://api.github.com/repos/openssl/openssl/releases" while url: - response = requests.get(url, timeout=30) - response.raise_for_status() + response = _fetch(url) matching = [ release for release in response.json() @@ -568,7 +574,7 @@ class OpenSSLVersionsDirectory(KeyedList[_OpenSSLVersionInfo, packaging.version. for asset in j_release['assets'] if urllib.parse.urlparse(asset['browser_download_url']).path.split('/')[-1].endswith('.sha256') ) - shasum_text = requests.get(shasum_url, timeout=30).text + shasum_text = _fetch(shasum_url).text shasum_data = jc.parse("hashsum", shasum_text, quiet=True)[0] package_hash, package_filename = shasum_data["hash"], shasum_data["filename"] del shasum_data, shasum_text, shasum_url