Commit 8b4ba753 authored by Stavros Sachtouris's avatar Stavros Sachtouris

Merge astakos error classes --> AstakosClientError

Refs: #5002

Also, decorate kamaki.clients.astakos.AstakosClient to raise this new class
when an error occurs
parent f6a5ef7a
This diff is collapsed.
......@@ -133,8 +133,8 @@ class user_authenticate(_init_synnefo_astakosclient, _optional_json):
class user_uuid2name(_init_synnefo_astakosclient, _optional_json):
"""Get user name(s) from uuid(s)"""
def _run(self, uuids):
r = self.client.get_usernames(uuids)
self._print(r, self.print_dict)
......@@ -38,9 +38,23 @@ from astakosclient import AstakosClientException, parse_endpoints
from kamaki.clients import Client, ClientError, RequestManager, recvlog
class AstakosClientError(AstakosClientException, ClientError):
"""Join AstakosClientException as ClientError in one class"""
def _astakos_error(foo):
def wrap(self, *args, **kwargs):
return foo(self, *args, **kwargs)
except AstakosClientException as sace:
raise AstakosClientError('%s' % sace, sace.status, sace.details)
return wrap
class AstakosClient(OriginalAstakosClient):
"""Wrap Original AstakosClient to ensure compatibility in kamaki clients"""
def __init__(self, *args, **kwargs):
if args:
args = list(args)
......@@ -64,13 +78,11 @@ class AstakosClient(OriginalAstakosClient):
return self.user_info[term]
def _astakos_error(foo):
def wrap(self, *args, **kwargs):
return foo(self, *args, **kwargs)
except AstakosClientException as sace:
return wrap
# Wrap AstakosClient public methods to raise AstakosClientError
from inspect import getmembers
for m in getmembers(AstakosClient):
if hasattr(m[1], '__call__') and not ('%s' % m[0]).startswith('_'):
setattr(AstakosClient, m[0], _astakos_error(m[1]))
class LoggedAstakosClient(AstakosClient):
......@@ -619,9 +619,7 @@ class PithosClient(PithosRestClient):
tries -= 1
old_failures = len(missing)
if missing:
raise ClientError(
'%s blocks failed to upload' % len(missing),
details=['%s' % thread.exception for thread in missing])
raise ClientError('%s blocks failed to upload' % len(missing))
except KeyboardInterrupt:'- - - wait for threads to finish')
for thread in activethreads():
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