~ubuntu-branches/ubuntu/trusty/python-cinderclient/trusty

« back to all changes in this revision

Viewing changes to cinderclient/openstack/common/apiclient/exceptions.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2014-03-06 15:15:14 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20140306151514-ihbixyaopbhaqdju
Tags: 1:1.0.8-0ubuntu1
* New upstream release.
* debian/patches/fix-search-opts.patch: Dropped no longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
 
 
3
1
# Copyright 2010 Jacob Kaplan-Moss
4
2
# Copyright 2011 Nebula, Inc.
5
3
# Copyright 2013 Alessio Ababilov
22
20
Exception definitions.
23
21
"""
24
22
 
 
23
import inspect
25
24
import sys
26
25
 
 
26
import six
 
27
 
27
28
 
28
29
class ClientException(Exception):
29
30
    """The base exception class for all exceptions this library raises.
59
60
    pass
60
61
 
61
62
 
 
63
class ConnectionRefused(ClientException):
 
64
    """Cannot connect to API service."""
 
65
    pass
 
66
 
 
67
 
62
68
class AuthPluginOptionsMissing(AuthorizationFailure):
63
69
    """Auth plugin misses some options."""
64
70
    def __init__(self, opt_names):
387
393
    message = "HTTP Version Not Supported"
388
394
 
389
395
 
390
 
# In Python 2.4 Exception is old-style and thus doesn't have a __subclasses__()
391
 
# so we can do this:
392
 
#     _code_map = dict((c.http_status, c)
393
 
#                      for c in HttpError.__subclasses__())
394
 
_code_map = {}
395
 
for obj in sys.modules[__name__].__dict__.values():
396
 
    if isinstance(obj, type):
397
 
        try:
398
 
            http_status = obj.http_status
399
 
        except AttributeError:
400
 
            pass
401
 
        else:
402
 
            if http_status:
403
 
                _code_map[http_status] = obj
 
396
# _code_map contains all the classes that have http_status attribute.
 
397
_code_map = dict(
 
398
    (getattr(obj, 'http_status', None), obj)
 
399
    for name, obj in six.iteritems(vars(sys.modules[__name__]))
 
400
    if inspect.isclass(obj) and getattr(obj, 'http_status', False)
 
401
)
404
402
 
405
403
 
406
404
def from_response(response, method, url):