Loading cloudcontrol/server/clients/__init__.py +23 −1 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ from functools import partial from datetime import datetime from sjrpc.utils import ConnectionProxy from sjrpc.core import RpcError from cloudcontrol.server.handlers import CCHandler, listed from cloudcontrol.server.exceptions import RightError Loading @@ -17,6 +18,27 @@ from cloudcontrol.common.tql.db.tag import StaticTag, CallbackTag from cloudcontrol.common.tql.db.object import TqlObject class CCServerConnectionProxy(ConnectionProxy): """ RPC proxy used to add the node login in the exception message. """ def __init__(self, login, *args, **kwargs): super(CCServerConnectionProxy, self).__init__(*args, **kwargs) self._login = login def __getattr__(self, name): def func(*args, **kwargs): try: return super(CCServerConnectionProxy, self).__getattr__(name)(*args, **kwargs) except RpcError as err: err.message = '%s: %s' % (self._login, err.message) raise err except Exception as err: raise err.__class__('%s: %s' % (self._login, str(err))) return func class RegisteredCCHandler(CCHandler): """ Basic handler for all registered clients. Loading Loading @@ -160,7 +182,7 @@ class Client(object): self._server = server self._connection = connection self._handler = self.RPC_HANDLER(self) self._proxy = ConnectionProxy(self._connection.rpc) self._proxy = CCServerConnectionProxy(login, self._connection.rpc) self._last_action = datetime.now() self._connection_date = datetime.now() self._tql_object = None Loading Loading
cloudcontrol/server/clients/__init__.py +23 −1 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ from functools import partial from datetime import datetime from sjrpc.utils import ConnectionProxy from sjrpc.core import RpcError from cloudcontrol.server.handlers import CCHandler, listed from cloudcontrol.server.exceptions import RightError Loading @@ -17,6 +18,27 @@ from cloudcontrol.common.tql.db.tag import StaticTag, CallbackTag from cloudcontrol.common.tql.db.object import TqlObject class CCServerConnectionProxy(ConnectionProxy): """ RPC proxy used to add the node login in the exception message. """ def __init__(self, login, *args, **kwargs): super(CCServerConnectionProxy, self).__init__(*args, **kwargs) self._login = login def __getattr__(self, name): def func(*args, **kwargs): try: return super(CCServerConnectionProxy, self).__getattr__(name)(*args, **kwargs) except RpcError as err: err.message = '%s: %s' % (self._login, err.message) raise err except Exception as err: raise err.__class__('%s: %s' % (self._login, str(err))) return func class RegisteredCCHandler(CCHandler): """ Basic handler for all registered clients. Loading Loading @@ -160,7 +182,7 @@ class Client(object): self._server = server self._connection = connection self._handler = self.RPC_HANDLER(self) self._proxy = ConnectionProxy(self._connection.rpc) self._proxy = CCServerConnectionProxy(login, self._connection.rpc) self._last_action = datetime.now() self._connection_date = datetime.now() self._tql_object = None Loading