Merge pull request #2 from tsufiev/master
Change client to return both response code and response body.
This commit is contained in:
commit
49f93b1834
@ -62,10 +62,6 @@ class HTTPMultipleChoices(HTTPException):
|
||||
self.details)
|
||||
|
||||
|
||||
class HTTPNotModified(HTTPException):
|
||||
code = 304
|
||||
|
||||
|
||||
class BadRequest(HTTPException):
|
||||
"""DEPRECATED!"""
|
||||
code = 400
|
||||
|
@ -235,7 +235,7 @@ class HTTPClient(object):
|
||||
elif resp.status in (301, 302, 305):
|
||||
# Redirected. Reissue the request to the new location.
|
||||
return self._http_request(resp['location'], method, **kwargs)
|
||||
elif resp.status in (300, 304):
|
||||
elif resp.status == 300:
|
||||
raise exc.from_response(resp)
|
||||
|
||||
return resp, body_iter
|
||||
|
@ -33,20 +33,27 @@ class Controller(object):
|
||||
def __init__(self, http_client):
|
||||
self.http_client = http_client
|
||||
|
||||
def get_ui_data(self):
|
||||
def _get_data(self, endpoint_type, hash_sum=None):
|
||||
if hash_sum:
|
||||
url = '/v1/client/{0}?hash={1}'.format(endpoint_type, hash_sum)
|
||||
else:
|
||||
url = '/v1/client/{0}'.format(endpoint_type)
|
||||
return self.http_client.raw_request('GET', url)
|
||||
|
||||
def get_ui_data(self, hash_sum=None):
|
||||
"""
|
||||
Download tar.gz with
|
||||
Download tar.gz with ui metadata. Returns a tuple
|
||||
(status, body_iterator) where status can be either 200 or 304. In the
|
||||
304 case there is no sense in iterating with body_iterator.
|
||||
|
||||
"""
|
||||
url = '/v1/client/ui'
|
||||
resp, body = self.http_client.raw_request('GET', url)
|
||||
return body
|
||||
return self._get_data('ui', hash_sum=hash_sum)
|
||||
|
||||
def get_conductor_data(self):
|
||||
def get_conductor_data(self, hash_sum=None):
|
||||
"""
|
||||
Download tar.gz with
|
||||
Download tar.gz with conductor metadata. Returns a tuple
|
||||
(status, body_iterator) where status can be either 200 or 304. In the
|
||||
304 case there is no sense in iterating with body_iterator.
|
||||
|
||||
"""
|
||||
url = '/v1/client/conductor'
|
||||
resp, body = self.http_client.raw_request('GET', url)
|
||||
return body
|
||||
return self._get_data('conductor', hash_sum=hash_sum)
|
||||
|
Loading…
x
Reference in New Issue
Block a user