From be68515fdc35207b14cd1542a7cd631778480c9a Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Tue, 10 Feb 2009 08:40:05 +0000 Subject: [PATCH] Have the client module automatically try to get the localhost creds in connect() --- deluge/ui/client.py | 7 +++++++ deluge/ui/gtkui/connectionmanager.py | 8 +------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/deluge/ui/client.py b/deluge/ui/client.py index e18a50c55..afbbf064d 100644 --- a/deluge/ui/client.py +++ b/deluge/ui/client.py @@ -146,6 +146,7 @@ class DelugeRPCProtocol(Protocol): if message_type == RPC_EVENT: event = request[1] + #log.debug("Received RPCEvent: %s", event) # A RPCEvent was received from the daemon so run any handlers # associated with it. if event in self.factory.event_handlers: @@ -463,6 +464,12 @@ class Client(object): :returns: a Deferred object that will be called once the connection has been established or fails """ + if not username and host in ("127.0.0.1", "localhost"): + # No username was provided and it's the localhost, so we can try + # to grab the credentials from the auth file. + import common + username, password = common.get_localhost_auth() + self._daemon_proxy = DaemonSSLProxy(self.__event_handlers) self._daemon_proxy.set_disconnect_callback(self.__on_disconnect) d = self._daemon_proxy.connect(host, port, username, password) diff --git a/deluge/ui/gtkui/connectionmanager.py b/deluge/ui/gtkui/connectionmanager.py index bf204b03d..891ae6c64 100644 --- a/deluge/ui/gtkui/connectionmanager.py +++ b/deluge/ui/gtkui/connectionmanager.py @@ -282,9 +282,6 @@ class ConnectionManager(component.Component): client.daemon.info().addCallback(on_info) continue - if host in ("127.0.0.1", "localhost") and not user: - # We need to get the localhost creds - user, password = deluge.ui.common.get_localhost_auth() # Create a new Client instance c = deluge.ui.client.Client() d = c.connect(host, port, user, password) @@ -393,10 +390,7 @@ class ConnectionManager(component.Component): port = model[row][HOSTLIST_COL_PORT] user = model[row][HOSTLIST_COL_USER] password = model[row][HOSTLIST_COL_PASS] - if not user and host in ("127.0.0.1", "localhost"): - # This is a localhost connection with no username, so lets try to - # get the localclient creds from the auth file. - user, password = deluge.ui.common.get_localhost_auth() + client.connect(host, port, user, password).addCallback(self.__on_connected, host_id) self.connection_manager.response(gtk.RESPONSE_OK)