From 45d8eecf5dd930c49cd85d5c68797e77161c81da Mon Sep 17 00:00:00 2001 From: Alex Xu Date: Tue, 26 Nov 2024 14:51:47 -0500 Subject: [PATCH 1/2] fix: add User-Agent headers to github request --- src/rocm_docs/theme.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/rocm_docs/theme.py b/src/rocm_docs/theme.py index 43fadad9..16ce1e1c 100644 --- a/src/rocm_docs/theme.py +++ b/src/rocm_docs/theme.py @@ -21,14 +21,17 @@ def _get_version_from_url(url: str) -> str: + headers = { + "User-Agent": "alexxu-amd" + } try: retry_counter = 0 - response = requests.get(url) + response = requests.get(url, headers=headers) # Retry in case of failure while (response.status_code != 200) and (retry_counter <= MAX_RETRY): time.sleep(5) - response = requests.get(url) + response = requests.get(url, headers=headers) if retry_counter > MAX_RETRY: raise requests.RequestException( @@ -55,16 +58,16 @@ def _add_custom_context( header_release_candidate_version = _get_version_from_url( "https://raw.githubusercontent.com/ROCm/rocm-docs-core/data/release_candidate.txt" ) - context[ - "header_release_candidate_version" - ] = header_release_candidate_version + context["header_release_candidate_version"] = ( + header_release_candidate_version + ) google_site_verification_content = _get_version_from_url( "https://raw.githubusercontent.com/ROCm/rocm-docs-core/data/google_site_verification.txt" ) - context[ - "google_site_verification_content" - ] = google_site_verification_content + context["google_site_verification_content"] = ( + google_site_verification_content + ) def _update_repo_opts(srcdir: str, theme_opts: dict[str, Any]) -> None: From 125d8d1cb0540e6bbfc395027eb873aecfc8ef77 Mon Sep 17 00:00:00 2001 From: Sam Wu <22262939+samjwu@users.noreply.github.com> Date: Wed, 27 Nov 2024 11:53:53 -0700 Subject: [PATCH 2/2] style(theme.py): Apply black to theme.py --- src/rocm_docs/theme.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/rocm_docs/theme.py b/src/rocm_docs/theme.py index 16ce1e1c..a7b0cf3c 100644 --- a/src/rocm_docs/theme.py +++ b/src/rocm_docs/theme.py @@ -21,9 +21,7 @@ def _get_version_from_url(url: str) -> str: - headers = { - "User-Agent": "alexxu-amd" - } + headers = {"User-Agent": "alexxu-amd"} try: retry_counter = 0 response = requests.get(url, headers=headers)