Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Timeout support#39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
gpocentek merged 1 commit intopython-gitlab:masterfrommjmaenpaa:timeout
Oct 13, 2014
Merged
Changes fromall 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
33 changes: 23 additions & 10 deletionsgitlab.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -75,15 +75,19 @@ class GitlabAuthenticationError(Exception):
class Gitlab(object):
"""Represents a GitLab server connection"""
def __init__(self, url, private_token=None,
email=None, password=None, ssl_verify=True):
email=None, password=None, ssl_verify=True, timeout=None):
"""Stores informations about the server

url: the URL of the Gitlab server
private_token: the user private token
email: the user email/login
password: the user password (associated with email)
ssl_verify: (Passed to requests-library)
timeout: (Passed to requests-library). Timeout to use for requests to
gitlab server. Float or tuple(Float,Float).
"""
self._url = '%s/api/v3' % url
self.timeout = timeout
self.setToken(private_token)
self.email = email
self.password = password
Expand DownExpand Up@@ -141,7 +145,8 @@ def rawGet(self, path, **kwargs):
try:
return requests.get(url,
headers=self.headers,
verify=self.ssl_verify)
verify=self.ssl_verify,
timeout=self.timeout)
except:
raise GitlabConnectionError(
"Can't connect to GitLab server (%s)" % self._url)
Expand All@@ -151,7 +156,8 @@ def rawPost(self, path, data=None):
try:
return requests.post(url, data,
headers=self.headers,
verify=self.ssl_verify)
verify=self.ssl_verify,
timeout=self.timeout)
except:
raise GitlabConnectionError(
"Can't connect to GitLab server (%s)" % self._url)
Expand All@@ -162,7 +168,8 @@ def rawPut(self, path):
try:
return requests.put(url,
headers=self.headers,
verify=self.ssl_verify)
verify=self.ssl_verify,
timeout=self.timeout)
except:
raise GitlabConnectionError(
"Can't connect to GitLab server (%s)" % self._url)
Expand All@@ -173,7 +180,8 @@ def rawDelete(self, path):
try:
return requests.delete(url,
headers=self.headers,
verify=self.ssl_verify)
verify=self.ssl_verify,
timeout=self.timeout)
except:
raise GitlabConnectionError(
"Can't connect to GitLab server (%s)" % self._url)
Expand All@@ -195,7 +203,8 @@ def list(self, obj_class, **kwargs):
["%s=%s" % (k, v) for k, v in args.items()]))

try:
r = requests.get(url, headers=self.headers, verify=self.ssl_verify)
r = requests.get(url, headers=self.headers, verify=self.ssl_verify,
timeout=self.timeout)
except:
raise GitlabConnectionError(
"Can't connect to GitLab server (%s)" % self._url)
Expand DownExpand Up@@ -233,7 +242,8 @@ def get(self, obj_class, id=None, **kwargs):
url = '%s%s' % (self._url, url)

try:
r = requests.get(url, headers=self.headers, verify=self.ssl_verify)
r = requests.get(url, headers=self.headers, verify=self.ssl_verify,
timeout=self.timeout)
except:
raise GitlabConnectionError(
"Can't connect to GitLab server (%s)" % self._url)
Expand All@@ -255,7 +265,8 @@ def delete(self, obj):
try:
r = requests.delete(url,
headers=self.headers,
verify=self.ssl_verify)
verify=self.ssl_verify,
timeout=self.timeout)
except:
raise GitlabConnectionError(
"Can't connect to GitLab server (%s)" % self._url)
Expand DownExpand Up@@ -288,7 +299,8 @@ def create(self, obj):
try:
r = requests.post(url, obj.__dict__,
headers=self.headers,
verify=self.ssl_verify)
verify=self.ssl_verify,
timeout=self.timeout)
except:
raise GitlabConnectionError(
"Can't connect to GitLab server (%s)" % self._url)
Expand DownExpand Up@@ -318,7 +330,8 @@ def update(self, obj):
try:
r = requests.put(url, d,
headers=self.headers,
verify=self.ssl_verify)
verify=self.ssl_verify,
timeout=self.timeout)
except:
raise GitlabConnectionError(
"Can't connect to GitLab server (%s)" % self._url)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp