|
41 | 41 |
|
42 | 42 | timeout = 10 |
43 | 43 |
|
| 44 | +Use ``proxy`` to configure the proxy. See the `Proxies`__ documentation |
| 45 | +for the format of proxy url. |
| 46 | +
|
| 47 | +__ https://requests.readthedocs.io/en/latest/user/advanced/#proxies |
44 | 48 | """ # noqa: W505,E501 # pylint:disable=line-too-long |
45 | 49 |
|
46 | 50 | import json |
@@ -75,10 +79,11 @@ class GitHub(): |
75 | 79 | # pylint: disable=too-few-public-methods |
76 | 80 |
|
77 | 81 | def __init__(self, *, url, token=None, user=None, |
78 | | - org=None, repo=None, exclude_org=None, timeout=TIMEOUT): |
| 82 | + org=None, repo=None, exclude_org=None, timeout=TIMEOUT, proxy=None): |
79 | 83 | """ Initialize url and headers """ |
80 | 84 | self.url = url.rstrip("/") |
81 | 85 | self.timeout = timeout |
| 86 | + self.proxy = {"all": proxy} |
82 | 87 | if token is not None: |
83 | 88 | self.headers = {'Authorization': f'token {token}'} |
84 | 89 | else: |
@@ -134,7 +139,7 @@ def request(self, url): |
134 | 139 | reraise=True): |
135 | 140 | with attempt: |
136 | 141 | response = requests.get( |
137 | | - url, headers=self.headers, timeout=self.timeout |
| 142 | + url, headers=self.headers, timeout=self.timeout, proxies=self.proxy |
138 | 143 | ) |
139 | 144 | log.debug("Response headers:\n%s", response.headers) |
140 | 145 | except (requests.exceptions.RequestException, RetryError) as error: |
@@ -377,7 +382,9 @@ def __init__(self, option, name=None, parent=None, user=None): |
377 | 382 | user=config.get("user"), |
378 | 383 | repo=config.get("repo"), |
379 | 384 | exclude_org=config.get("exclude_org"), |
380 | | - timeout=config.get("timeout")) |
| 385 | + timeout=config.get("timeout"), |
| 386 | + proxy=config.get("proxy"), |
| 387 | + ) |
381 | 388 |
|
382 | 389 | # Create the list of stats |
383 | 390 | self.stats = [ |
|
0 commit comments