Module: deluge Branch: multiuser Commit: 05e3d5aa808414053ff72430c5371159a43428fc
Author: Pedro Algarvio <[email protected]> Date: Wed Dec 22 09:12:13 2010 +0000 Remove unused method, duplicate log messages and add a method to get the logged in user's authentication level. --- deluge/ui/client.py | 32 +++++++++++++++++++------------- 1 files changed, 19 insertions(+), 13 deletions(-) diff --git a/deluge/ui/client.py b/deluge/ui/client.py index a9c5662..7be876a 100644 --- a/deluge/ui/client.py +++ b/deluge/ui/client.py @@ -227,14 +227,17 @@ class DelugeRPCClientFactory(ClientFactory): self.bytes_sent = 0 def startedConnecting(self, connector): - log.info("Connecting to daemon at %s:%s..", connector.host, connector.port) + log.info("Connecting to daemon at \"%s:%s\"...", + connector.host, connector.port) def clientConnectionFailed(self, connector, reason): - log.warning("Connection to daemon at %s:%s failed: %s", connector.host, connector.port, reason.value) + log.warning("Connection to daemon at \"%s:%s\" failed: %s", + connector.host, connector.port, reason.value) self.daemon.connect_deferred.errback(reason) def clientConnectionLost(self, connector, reason): - log.info("Connection lost to daemon at %s:%s reason: %s", connector.host, connector.port, reason.value) + log.info("Connection lost to daemon at \"%s:%s\" reason: %s", + connector.host, connector.port, reason.value) self.daemon.host = None self.daemon.port = None self.daemon.username = None @@ -261,6 +264,7 @@ class DaemonSSLProxy(DaemonProxy): self.host = None self.port = None self.username = None + self.authentication_level = 0 self.connected = False @@ -430,8 +434,6 @@ class DaemonSSLProxy(DaemonProxy): return self.daemon_info_deferred def __on_connect_fail(self, reason): - log.debug("__on_connect_fail called") - log.exception(reason) self.daemon_info_deferred.errback(reason) def authenticate(self, username, password): @@ -445,6 +447,7 @@ class DaemonSSLProxy(DaemonProxy): def __on_login(self, result, username): log.debug("__on_login called: %s %s", username, result) self.username = username + self.authentication_level = result # We need to tell the daemon what events we're interested in receiving if self.__factory.event_handlers: self.call("daemon.set_event_interest", self.__factory.event_handlers.keys()) @@ -576,10 +579,9 @@ class Client(object): self._daemon_proxy = DaemonSSLProxy(dict(self.__event_handlers)) self._daemon_proxy.set_disconnect_callback(self.__on_disconnect) d = self._daemon_proxy.connect(host, port) - def on_connect_fail(result): - log.debug("on_connect_fail: %s", result) + def on_connect_fail(reason): self.disconnect() - return result + return reason d.addErrback(on_connect_fail) if not skip_authentication: @@ -587,7 +589,6 @@ class Client(object): def on_authenticate(result, daemon_info): log.debug("Authentication sucessfull: %s", result) - self.authentication_level = result auth_deferred.callback(daemon_info) def on_authenticate_fail(reason): @@ -651,10 +652,6 @@ class Client(object): else: return True - def daemon_info(self): - return self._daemon_proxy.daemon_info_deferred - return defer.succeed(self._daemon_proxy.daemon_info or None) - def is_localhost(self): """ Checks if the current connected host is a localhost or not. @@ -759,5 +756,14 @@ class Client(object): """ return self._daemon_proxy.get_bytes_sent() + def get_auth_level(self): + """ + Returns the authentication level the daemon returned upon authentication. + + :returns: the authentication level + :rtype: int + """ + return self._daemon_proxy.authentication_level + # This is the object clients will use client = Client() -- You received this message because you are subscribed to the Google Groups "deluge-commit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/deluge-commit?hl=en.
