Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions did/plugins/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@

timeout = 10

Use ``proxy`` to configure the proxy. See the `Proxies`__ documentation
for the format of proxy url.

__ https://requests.readthedocs.io/en/latest/user/advanced/#proxies
""" # noqa: W505,E501 # pylint:disable=line-too-long

import json
Expand Down Expand Up @@ -75,10 +79,11 @@ class GitHub():
# pylint: disable=too-few-public-methods

def __init__(self, *, url, token=None, user=None,
org=None, repo=None, exclude_org=None, timeout=TIMEOUT):
org=None, repo=None, exclude_org=None, timeout=TIMEOUT, proxy=None):
""" Initialize url and headers """
self.url = url.rstrip("/")
self.timeout = timeout
self.proxy = {"all": proxy}
if token is not None:
self.headers = {'Authorization': f'token {token}'}
else:
Expand Down Expand Up @@ -134,8 +139,7 @@ def request(self, url):
reraise=True):
with attempt:
response = requests.get(
url, headers=self.headers, timeout=self.timeout
)
url, headers=self.headers, timeout=self.timeout, proxies=self.proxy)
log.debug("Response headers:\n%s", response.headers)
except (requests.exceptions.RequestException, RetryError) as error:
log.debug(error)
Expand Down Expand Up @@ -377,7 +381,9 @@ def __init__(self, option, name=None, parent=None, user=None):
user=config.get("user"),
repo=config.get("repo"),
exclude_org=config.get("exclude_org"),
timeout=config.get("timeout"))
timeout=config.get("timeout"),
proxy=config.get("proxy"),
)

# Create the list of stats
self.stats = [
Expand Down
22 changes: 19 additions & 3 deletions did/plugins/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
token_file = <authentication-token-file>
login = <username>
ssl_verify = true
proxy = <proxy-url>

The authentication token is required. Create it in the GitLab web
interface (select ``api`` as the desired scope). See the `GitLab API`__
Expand All @@ -27,6 +28,10 @@

__ https://docs.gitlab.com/ce/api/

Use ``proxy`` to configure the proxy. See the `Proxies`__ documentation
for the format of proxy url.

__ https://requests.readthedocs.io/en/latest/user/advanced/#proxies
"""

from time import sleep
Expand Down Expand Up @@ -61,7 +66,13 @@
class GitLab():
""" GitLab Investigator """

def __init__(self, url, token, ssl_verify=GITLAB_SSL_VERIFY, timeout=TIMEOUT):
def __init__(
self,
url,
token,
ssl_verify=GITLAB_SSL_VERIFY,
timeout=TIMEOUT,
proxy=None):
""" Initialize url and headers """
self.url = url.rstrip("/")
self.headers = {'PRIVATE-TOKEN': token}
Expand All @@ -73,6 +84,7 @@ def __init__(self, url, token, ssl_verify=GITLAB_SSL_VERIFY, timeout=TIMEOUT):
self.project_mrs = {}
self.project_issues = {}
self.timeout = timeout
self.proxy = {"all": proxy}

def _get_gitlab_api_raw(self, url):
log.debug("Connecting to GitLab API at '%s'.", url)
Expand All @@ -81,7 +93,7 @@ def _get_gitlab_api_raw(self, url):
try:
api_raw = requests.get(
url, headers=self.headers, verify=self.ssl_verify,
timeout=self.timeout)
timeout=self.timeout, proxies=self.proxy)
api_raw.raise_for_status()
return api_raw
except requests.exceptions.HTTPError as http_err:
Expand Down Expand Up @@ -427,7 +439,11 @@ def __init__(self, option, name=None, parent=None, user=None):
if not self.ssl_verify:
urllib3.disable_warnings(InsecureRequestWarning)
self.gitlab = GitLab(
self.url, self.token, self.ssl_verify, timeout=config.get("timeout"))
self.url,
self.token,
self.ssl_verify,
timeout=config.get("timeout"),
proxy=config.get("proxy"))
# Create the list of stats
self.stats = [
IssuesCreated(
Expand Down
Loading