Work around CDN rate limiting on Python.org in bin/update_pythons.py (#2753)
This commit is contained in:
@@ -266,9 +266,11 @@ class CPythonVersions:
|
|||||||
|
|
||||||
# Removing the prefix
|
# Removing the prefix
|
||||||
version = Version(release["name"].removeprefix("Python "))
|
version = Version(release["name"].removeprefix("Python "))
|
||||||
|
self.versions_dict[version] = release["resource_uri"]
|
||||||
|
|
||||||
uri = int(release["resource_uri"].rstrip("/").split("/")[-1])
|
files_response = requests.get("https://www.python.org/api/v2/downloads/release_file/")
|
||||||
self.versions_dict[version] = uri
|
files_response.raise_for_status()
|
||||||
|
self.files_info = files_response.json()
|
||||||
|
|
||||||
def update_version(self, identifier: str, spec: Specifier, file_ident: str) -> ConfigUrl | None:
|
def update_version(self, identifier: str, spec: Specifier, file_ident: str) -> ConfigUrl | None:
|
||||||
# see note above on Specifier.filter
|
# see note above on Specifier.filter
|
||||||
@@ -278,13 +280,9 @@ class CPythonVersions:
|
|||||||
for new_version in sorted_versions:
|
for new_version in sorted_versions:
|
||||||
# Find the first patch version that contains the requested file
|
# Find the first patch version that contains the requested file
|
||||||
uri = self.versions_dict[new_version]
|
uri = self.versions_dict[new_version]
|
||||||
response = requests.get(
|
files = [rf for rf in self.files_info if rf["release"] == uri]
|
||||||
f"https://www.python.org/api/v2/downloads/release_file/?release={uri}"
|
|
||||||
)
|
|
||||||
response.raise_for_status()
|
|
||||||
file_info = response.json()
|
|
||||||
|
|
||||||
urls = [rf["url"] for rf in file_info if file_ident in rf["url"]]
|
urls = [rf["url"] for rf in files if file_ident in rf["url"]]
|
||||||
if urls:
|
if urls:
|
||||||
return ConfigUrl(
|
return ConfigUrl(
|
||||||
identifier=identifier,
|
identifier=identifier,
|
||||||
|
|||||||
Reference in New Issue
Block a user