diff options
| author | Gauvain Pocentek <gauvain@pocentek.net> | 2017-05-28 22:10:27 +0200 |
|---|---|---|
| committer | Gauvain Pocentek <gauvain@pocentek.net> | 2017-06-02 15:42:32 +0200 |
| commit | f418767ec94c430aabd132d189d1c5e9e2370e68 (patch) | |
| tree | a015a30cf17ae755f35a6d1618b2d2a1cccb4472 /gitlab/__init__.py | |
| parent | 0467f779eb1d2649f3626e3817531511d3397038 (diff) | |
| download | gitlab-f418767ec94c430aabd132d189d1c5e9e2370e68.tar.gz | |
Migrate all v4 objects to new API
Some things are probably broken. Next step is writting unit and
functional tests.
And fix.
Diffstat (limited to 'gitlab/__init__.py')
| -rw-r--r-- | gitlab/__init__.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py index 2ea5e14..e9a7e9a 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -683,7 +683,7 @@ class Gitlab(object): raise GitlaParsingError( message="Failed to parse the server message") else: - return r + return result def http_list(self, path, query_data={}, **kwargs): """Make a GET request to the Gitlab server for list-oriented queries. @@ -722,7 +722,8 @@ class Gitlab(object): **kwargs: Extra data to make the query (e.g. sudo, per_page, page) Returns: - The parsed json returned by the server. + The parsed json returned by the server if json is return, else the + raw content. Raises: GitlabHttpError: When the return code is not 2xx @@ -730,11 +731,14 @@ class Gitlab(object): """ result = self.http_request('post', path, query_data=query_data, post_data=post_data, **kwargs) - try: - return result.json() - except Exception: - raise GitlabParsingError( - message="Failed to parse the server message") + if result.headers.get('Content-Type', None) == 'application/json': + try: + return result.json() + except Exception: + raise GitlabParsingError( + message="Failed to parse the server message") + else: + return result.content def http_put(self, path, query_data={}, post_data={}, **kwargs): """Make a PUT request to the Gitlab server. |
