UI client.connect() with no credentials/username now attempts connect using localhost auth file details

This commit is contained in:
Calum Lind 2013-05-16 02:30:52 +01:00
parent 391513d378
commit 3101104738
1 changed files with 6 additions and 1 deletions

View File

@ -44,6 +44,7 @@ import deluge.common
from deluge import error from deluge import error
from deluge.event import known_events from deluge.event import known_events
from deluge.transfer import DelugeTransferProtocol from deluge.transfer import DelugeTransferProtocol
from deluge.ui.common import get_localhost_auth
RPC_RESPONSE = 1 RPC_RESPONSE = 1
RPC_ERROR = 2 RPC_ERROR = 2
@ -561,7 +562,7 @@ class Client(object):
return reason return reason
def on_authenticate(result, daemon_info): def on_authenticate(result, daemon_info):
log.debug("Authentication sucessfull: %s", result) log.debug("Authentication successful: %s", result)
return result return result
def on_authenticate_fail(reason): def on_authenticate_fail(reason):
@ -574,6 +575,10 @@ class Client(object):
return daemon_version return daemon_version
def authenticate(daemon_version, username, password): def authenticate(daemon_version, username, password):
if not username and host in ("127.0.0.1", "localhost"):
# No username provided and it's localhost, so attempt to get credentials from auth file.
username, password = get_localhost_auth()
d = self._daemon_proxy.authenticate(username, password) d = self._daemon_proxy.authenticate(username, password)
d.addCallback(on_authenticate, daemon_version) d.addCallback(on_authenticate, daemon_version)
d.addErrback(on_authenticate_fail) d.addErrback(on_authenticate_fail)