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

fix(api): Don't try to parse raw downloads#687

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
max-wittig merged 1 commit intomasterfromfix/683/raw_download
Jan 19, 2019
Merged
Show file tree
Hide file tree
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
10 changes: 7 additions & 3 deletionsgitlab/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -517,14 +517,16 @@ def http_request(self, verb, path, query_data={}, post_data=None,
error_message=error_message,
response_body=result.content)

def http_get(self, path, query_data={}, streamed=False, **kwargs):
def http_get(self, path, query_data={}, streamed=False, raw=False,
**kwargs):
"""Make a GET request to the Gitlab server.

Args:
path (str): Path or full URL to query ('/projects' or
'http://whatever/v4/api/projecs')
query_data (dict): Data to send as query parameters
streamed (bool): Whether the data should be streamed
raw (bool): If True do not try to parse the output as json
**kwargs: Extra options to send to the server (e.g. sudo)

Returns:
Expand All@@ -538,8 +540,10 @@ def http_get(self, path, query_data={}, streamed=False, **kwargs):
"""
result = self.http_request('get', path, query_data=query_data,
streamed=streamed, **kwargs)
if (result.headers['Content-Type'] == 'application/json' and
not streamed):

if (result.headers['Content-Type'] == 'application/json'
and not streamed
and not raw):
try:
return result.json()
except Exception:
Expand Down
21 changes: 11 additions & 10 deletionsgitlab/v4/objects.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1128,7 +1128,7 @@ def content(self, streamed=False, action=None, chunk_size=1024, **kwargs):
"""
path = '/snippets/%s/raw' % self.get_id()
result = self.manager.gitlab.http_get(path, streamed=streamed,
**kwargs)
raw=True,**kwargs)
return utils.response_content(result, streamed, action, chunk_size)


Expand DownExpand Up@@ -1365,7 +1365,7 @@ def artifacts(self, streamed=False, action=None, chunk_size=1024,
"""
path = '%s/%s/artifacts' % (self.manager.path, self.get_id())
result = self.manager.gitlab.http_get(path, streamed=streamed,
**kwargs)
raw=True,**kwargs)
return utils.response_content(result, streamed, action, chunk_size)

@cli.register_custom_action('ProjectJob')
Expand DownExpand Up@@ -1393,7 +1393,7 @@ def artifact(self, path, streamed=False, action=None, chunk_size=1024,
"""
path = '%s/%s/artifacts/%s' % (self.manager.path, self.get_id(), path)
result = self.manager.gitlab.http_get(path, streamed=streamed,
**kwargs)
raw=True,**kwargs)
return utils.response_content(result, streamed, action, chunk_size)

@cli.register_custom_action('ProjectJob')
Expand All@@ -1419,7 +1419,7 @@ def trace(self, streamed=False, action=None, chunk_size=1024, **kwargs):
"""
path = '%s/%s/trace' % (self.manager.path, self.get_id())
result = self.manager.gitlab.http_get(path, streamed=streamed,
**kwargs)
raw=True,**kwargs)
return utils.response_content(result, streamed, action, chunk_size)


Expand DownExpand Up@@ -2654,7 +2654,7 @@ def raw(self, file_path, ref, streamed=False, action=None, chunk_size=1024,
path = '%s/%s/raw' % (self.path, file_path)
query_data = {'ref': ref}
result = self.gitlab.http_get(path, query_data=query_data,
streamed=streamed, **kwargs)
streamed=streamed,raw=True,**kwargs)
return utils.response_content(result, streamed, action, chunk_size)


Expand DownExpand Up@@ -2897,7 +2897,7 @@ def content(self, streamed=False, action=None, chunk_size=1024, **kwargs):
"""
path = "%s/%s/raw" % (self.manager.path, self.get_id())
result = self.manager.gitlab.http_get(path, streamed=streamed,
**kwargs)
raw=True,**kwargs)
return utils.response_content(result, streamed, action, chunk_size)


Expand DownExpand Up@@ -3174,7 +3174,7 @@ def download(self, streamed=False, action=None, chunk_size=1024, **kwargs):
"""
path = '/projects/%d/export/download' % self.project_id
result = self.manager.gitlab.http_get(path, streamed=streamed,
**kwargs)
raw=True,**kwargs)
return utils.response_content(result, streamed, action, chunk_size)


Expand DownExpand Up@@ -3315,7 +3315,7 @@ def repository_raw_blob(self, sha, streamed=False, action=None,
"""
path = '/projects/%s/repository/blobs/%s/raw' % (self.get_id(), sha)
result = self.manager.gitlab.http_get(path, streamed=streamed,
**kwargs)
raw=True,**kwargs)
return utils.response_content(result, streamed, action, chunk_size)

@cli.register_custom_action('Project', ('from_', 'to'))
Expand DownExpand Up@@ -3391,7 +3391,8 @@ def repository_archive(self, sha=None, streamed=False, action=None,
if sha:
query_data['sha'] = sha
result = self.manager.gitlab.http_get(path, query_data=query_data,
streamed=streamed, **kwargs)
raw=True, streamed=streamed,
**kwargs)
return utils.response_content(result, streamed, action, chunk_size)

@cli.register_custom_action('Project', ('forked_from_id', ))
Expand DownExpand Up@@ -3674,7 +3675,7 @@ def snapshot(self, wiki=False, streamed=False, action=None,
"""
path = '/projects/%d/snapshot' % self.get_id()
result = self.manager.gitlab.http_get(path, streamed=streamed,
**kwargs)
raw=True,**kwargs)
return utils.response_content(result, streamed, action, chunk_size)

@cli.register_custom_action('Project', ('scope', 'search'))
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp