diff options
author | Dean Troyer <dtroyer@gmail.com> | 2012-11-16 17:43:05 -0600 |
---|---|---|
committer | Dean Troyer <dtroyer@gmail.com> | 2012-12-18 15:30:43 -0600 |
commit | 51dc6a0cef657cf9fa110da11d81d1c3f13194fa (patch) | |
tree | 80bda5aa2974db6102a60b06ea7422e107034940 /keystoneclient/exceptions.py | |
parent | 581264757e5ac8c5313acc35e5dc94247c7a80ff (diff) | |
download | python-keystoneclient-51dc6a0cef657cf9fa110da11d81d1c3f13194fa.tar.gz |
Use requests module for HTTP/HTTPS
* Implement correct certificate verification
* Add requests to tools/pip-requires
* Fix OS_CACERT env var help text
* Add info to README
* Rework tests to use requests
Pinned requests module to < 1.0 as 1.0.2 is now current in pipi
as of 17Dec2012.
Change-Id: I120d2c12d6f20ebe2fd7182ec8988cc73f623b80
Diffstat (limited to 'keystoneclient/exceptions.py')
-rw-r--r-- | keystoneclient/exceptions.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/keystoneclient/exceptions.py b/keystoneclient/exceptions.py index 0317879..213f078 100644 --- a/keystoneclient/exceptions.py +++ b/keystoneclient/exceptions.py @@ -130,15 +130,15 @@ _code_map = dict((c.http_status, c) for c in [BadRequest, def from_response(response, body): """ Return an instance of an ClientException or subclass - based on an httplib2 response. + based on an requests response. Usage:: - resp, body = http.request(...) - if resp.status != 200: - raise exception_from_response(resp, body) + resp = requests.request(...) + if resp.status_code != 200: + raise exception_from_response(resp, resp.text) """ - cls = _code_map.get(response.status, ClientException) + cls = _code_map.get(response.status_code, ClientException) if body: if hasattr(body, 'keys'): error = body[body.keys()[0]] @@ -149,6 +149,6 @@ def from_response(response, body): # probably couldn't communicate with Keystone at all. message = "Unable to communicate with identity service: %s." % body details = None - return cls(code=response.status, message=message, details=details) + return cls(code=response.status_code, message=message, details=details) else: - return cls(code=response.status) + return cls(code=response.status_code) |