Skip to content

Commit d95a928

Browse files
authored
Merge pull request #208 from creativecommons/github-used-shared
Update to use constants from shared library
2 parents 401fddd + d2d64b8 commit d95a928

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

scripts/1-fetch/github_fetch.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,6 @@
3232
# Constants
3333
FILE1_COUNT = os.path.join(PATHS["data_phase"], "github_1_count.csv")
3434
GH_TOKEN = os.getenv("GH_TOKEN")
35-
GITHUB_RETRY_STATUS_FORCELIST = [
36-
408, # Request Timeout
37-
422, # Unprocessable Content (Validation failed, or endpoint spammed)
38-
429, # Too Many Requests
39-
500, # Internal Server Error
40-
502, # Bad Gateway
41-
503, # Service Unavailable
42-
504, # Gateway Timeout
43-
]
4435
# Also see: https://en.wikipedia.org/wiki/Public-domain-equivalent_license
4536
GITHUB_TOOLS = [
4637
{"TOOL_IDENTIFIER": "BSD Zero Clause License", "SPDX_IDENTIFIER": "0BSD"},
@@ -93,11 +84,14 @@ def get_requests_session():
9384
max_retries = Retry(
9485
total=5,
9586
backoff_factor=10,
96-
status_forcelist=GITHUB_RETRY_STATUS_FORCELIST,
87+
status_forcelist=shared.STATUS_FORCELIST,
9788
)
9889
session = requests.Session()
9990
session.mount("https://", HTTPAdapter(max_retries=max_retries))
100-
headers = {"accept": "application/vnd.github+json"}
91+
headers = {
92+
"accept": "application/vnd.github+json",
93+
"User-Agent": shared.USER_AGENT,
94+
}
10195
if GH_TOKEN:
10296
headers["authorization"] = f"Bearer {GH_TOKEN}"
10397
session.headers.update(headers)

0 commit comments

Comments
 (0)