Commit ab6fd07d authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Fix AstakosClientError class hierarchy order

This bug caused AstakosClientError class to call both parent
class constructors, while only the AstakosClientException class
constructor needs to be called.
parent 4a892648
...@@ -39,16 +39,21 @@ from astakosclient import AstakosClientException, parse_endpoints ...@@ -39,16 +39,21 @@ from astakosclient import AstakosClientException, parse_endpoints
from kamaki.clients import Client, ClientError, RequestManager, recvlog from kamaki.clients import Client, ClientError, RequestManager, recvlog
class AstakosClientError(AstakosClientException, ClientError): class AstakosClientError(ClientError, AstakosClientException):
"""Join AstakosClientException as ClientError in one class""" """Join AstakosClientException as ClientError in one class"""
def __init__(self, message='Astakos Client Error', details='', status=0):
super(ClientError, self).__init__(message, details, status)
def _astakos_error(foo): def _astakos_error(foo):
def wrap(self, *args, **kwargs): def wrap(self, *args, **kwargs):
try: try:
return foo(self, *args, **kwargs) return foo(self, *args, **kwargs)
except AstakosClientException as sace: except AstakosClientException as sace:
raise AstakosClientError('%s' % sace, sace.status, sace.details) raise AstakosClientError(
getattr(sace, 'message', '%s' % sace),
details=sace.details, status=sace.status)
return wrap return wrap
...@@ -117,7 +122,7 @@ class LoggedAstakosClient(AstakosClient): ...@@ -117,7 +122,7 @@ class LoggedAstakosClient(AstakosClient):
if log_request: if log_request:
req = RequestManager( req = RequestManager(
method=log_request['method'], method=log_request['method'],
url='%s://%s' % (self.scheme, self.astakos_endpoint_url), url='%s://%s' % (self.scheme, self.astakos_base_url),
path=log_request['path'], path=log_request['path'],
data=log_request.get('body', None), data=log_request.get('body', None),
headers=log_request.get('headers', dict())) headers=log_request.get('headers', dict()))
...@@ -252,8 +257,7 @@ class CachedAstakosClient(Client): ...@@ -252,8 +257,7 @@ class CachedAstakosClient(Client):
raise AstakosClientError( raise AstakosClientError(
'%s endpoints match type %s %s' % ( '%s endpoints match type %s %s' % (
len(matches), service_type, len(matches), service_type,
('and versionId %s' % version) if version else ''), ('and versionId %s' % version) if version else ''))
601)
return matches[0] return matches[0]
def get_endpoint_url(self, service_type, version=None, token=None): def get_endpoint_url(self, service_type, version=None, token=None):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment