diff options
author | bendikro <bendikro@gmail.com> | 2013-05-23 01:43:00 +0100 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2013-05-26 15:25:39 +0100 |
commit | b76cdc2227f4e6aba9534b1d6ff3b7ea924ae1b5 (patch) | |
tree | 4ff6effa5f017b7acd73aeec7f105e7941fa8fe5 /deluge/ui/client.py | |
parent | a27b479f06cd481c705ead919104afcf6e347260 (diff) | |
download | deluge-b76cdc2227f4e6aba9534b1d6ff3b7ea924ae1b5.tar.gz deluge-b76cdc2227f4e6aba9534b1d6ff3b7ea924ae1b5.tar.bz2 deluge-b76cdc2227f4e6aba9534b1d6ff3b7ea924ae1b5.zip |
Fix 2247: AttributeError in deluge.error.DaemonRunningError
* Removed all the properties in error.py and added more tests
* Handle failure in client.py handling RPC_ERROR (From older daemons)
Diffstat (limited to 'deluge/ui/client.py')
-rw-r--r-- | deluge/ui/client.py | 71 |
1 files changed, 40 insertions, 31 deletions
diff --git a/deluge/ui/client.py b/deluge/ui/client.py index 8e8b8a44f..650dcfa45 100644 --- a/deluge/ui/client.py +++ b/deluge/ui/client.py @@ -150,37 +150,46 @@ class DelugeRPCProtocol(DelugeTransferProtocol): d.callback(request[2]) elif message_type == RPC_ERROR: # Recreate exception and errback'it - exception_cls = getattr(error, request[2]) - exception = exception_cls(*request[3], **request[4]) - - # Ideally we would chain the deferreds instead of instance - # checking just to log them. But, that would mean that any - # errback on the fist deferred should returns it's failure - # so it could pass back to the 2nd deferred on the chain. But, - # that does not always happen. - # So, just do some instance checking and just log rpc error at - # diferent levels. - r = self.__rpc_requests[request_id] - msg = "RPCError Message Received!" - msg += "\n" + "-" * 80 - msg += "\n" + "RPCRequest: " + r.__repr__() - msg += "\n" + "-" * 80 - if isinstance(exception, error.WrappedException): - msg += "\n" + exception.type + "\n" + exception.message + ": " - msg += exception.traceback - else: - msg += "\n" + request[5] + "\n" + request[2] + ": " - msg += str(exception) - msg += "\n" + "-" * 80 - - if not isinstance(exception, error._ClientSideRecreateError): - # Let's log these as errors - log.error(msg) - else: - # The rest just get's logged in debug level, just to log - # what's happening - log.debug(msg) - + try: + # The exception class is located in deluge.error + if hasattr(error, request[2]): + exception_cls = getattr(error, request[2]) + exception = exception_cls(*request[3], **request[4]) + else: + # Shouldn't happen + raise Exception("Received invalid exception: %s", request[2]) + + # Ideally we would chain the deferreds instead of instance + # checking just to log them. But, that would mean that any + # errback on the fist deferred should returns it's failure + # so it could pass back to the 2nd deferred on the chain. But, + # that does not always happen. + # So, just do some instance checking and just log rpc error at + # diferent levels. + r = self.__rpc_requests[request_id] + msg = "RPCError Message Received!" + msg += "\n" + "-" * 80 + msg += "\n" + "RPCRequest: " + r.__repr__() + msg += "\n" + "-" * 80 + if isinstance(exception, error.WrappedException): + msg += "\n" + exception.type + "\n" + exception.message + ": " + msg += exception.traceback + else: + msg += "\n" + request[5] + "\n" + request[2] + ": " + msg += str(exception) + msg += "\n" + "-" * 80 + + if not isinstance(exception, error._ClientSideRecreateError): + # Let's log these as errors + log.error(msg) + else: + # The rest just get's logged in debug level, just to log + # what's happening + log.debug(msg) + except: + # Failed probably because of invalid data (old daemon) + import traceback + log.error("Failed to handle RPC_ERROR (Old daemon?): %s\nLocal error: %s", request[2], traceback.format_exc()) d.errback(exception) del self.__rpc_requests[request_id] |