|
17 | 17 | from pygments import highlight |
18 | 18 | from pygments.formatters import TerminalFormatter |
19 | 19 | from pygments.lexers import PythonTracebackLexer |
20 | | -from requests.adapters import HTTPAdapter |
21 | | -from urllib3.util.retry import Retry |
22 | 20 |
|
23 | 21 | # Add parent directory so shared can be imported |
24 | 22 | sys.path.append(os.path.join(os.path.dirname(__file__), "..")) |
@@ -80,25 +78,6 @@ def check_for_completion(): |
80 | 78 | pass # File may not be found without --enable-save, etc. |
81 | 79 |
|
82 | 80 |
|
83 | | -def get_requests_session(): |
84 | | - max_retries = Retry( |
85 | | - total=5, |
86 | | - backoff_factor=10, |
87 | | - status_forcelist=shared.STATUS_FORCELIST, |
88 | | - ) |
89 | | - session = requests.Session() |
90 | | - session.mount("https://", HTTPAdapter(max_retries=max_retries)) |
91 | | - headers = { |
92 | | - "accept": "application/vnd.github+json", |
93 | | - "User-Agent": shared.USER_AGENT, |
94 | | - } |
95 | | - if GH_TOKEN: |
96 | | - headers["authorization"] = f"Bearer {GH_TOKEN}" |
97 | | - session.headers.update(headers) |
98 | | - |
99 | | - return session |
100 | | - |
101 | | - |
102 | 81 | def write_data(args, tool_data): |
103 | 82 | if not args.enable_save: |
104 | 83 | return args |
@@ -162,7 +141,12 @@ def main(): |
162 | 141 | args = parse_arguments() |
163 | 142 | shared.paths_log(LOGGER, PATHS) |
164 | 143 | check_for_completion() |
165 | | - session = get_requests_session() |
| 144 | + session = shared.get_session( |
| 145 | + accept_header="application/vnd.github+json", |
| 146 | + ) |
| 147 | + if GH_TOKEN: |
| 148 | + session.headers.update({"authorization": f"Bearer {GH_TOKEN}"}) |
| 149 | + |
166 | 150 | tool_data = query_github(args, session) |
167 | 151 | args = write_data(args, tool_data) |
168 | 152 | args = shared.git_add_and_commit( |
|
0 commit comments