Fix client.connect() not firing the errback when a login attempt result is 0 (meaning no
authorization) Fix console connect command
This commit is contained in:
parent
66243d1859
commit
b6793f7268
|
@ -384,6 +384,11 @@ class DaemonSSLProxy(DaemonProxy):
|
||||||
self.login_deferred.callback(False)
|
self.login_deferred.callback(False)
|
||||||
|
|
||||||
def __on_login(self, result, username):
|
def __on_login(self, result, username):
|
||||||
|
if not result:
|
||||||
|
# We received a 0 auth level from the server which means it failed
|
||||||
|
self.login_deferred.errback(result)
|
||||||
|
return
|
||||||
|
|
||||||
self.username = username
|
self.username = username
|
||||||
# We need to tell the daemon what events we're interested in receiving
|
# We need to tell the daemon what events we're interested in receiving
|
||||||
if self.__factory.event_handlers:
|
if self.__factory.event_handlers:
|
||||||
|
|
|
@ -40,13 +40,23 @@ import deluge.component as component
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
"""Connect to a new deluge server."""
|
"""Connect to a new deluge server."""
|
||||||
def handle(self, host="", port="58846", username="", password="", **options):
|
|
||||||
self.console = component.get("ConsoleUI")
|
|
||||||
|
|
||||||
|
usage = "Usage: connect <host[:port]> <username> <password>"
|
||||||
|
|
||||||
|
def handle(self, host="127.0.0.1:58846", username="", password="", **options):
|
||||||
|
self.console = component.get("ConsoleUI")
|
||||||
|
try:
|
||||||
|
host, port = host.split(":")
|
||||||
|
except ValueError:
|
||||||
|
port = 58846
|
||||||
|
else:
|
||||||
port = int(port)
|
port = int(port)
|
||||||
|
|
||||||
|
def on_disconnect(result):
|
||||||
d = client.connect(host, port, username, password)
|
d = client.connect(host, port, username, password)
|
||||||
def on_connect(result):
|
def on_connect(result):
|
||||||
self.console.write("{!success!}Connected to %s:%s!" % (host, port))
|
self.console.write("{!success!}Connected to %s:%s!" % (host, port))
|
||||||
|
component.start()
|
||||||
|
|
||||||
def on_connect_fail(result):
|
def on_connect_fail(result):
|
||||||
self.console.write("{!error!}Failed to connect to %s:%s!" % (host, port))
|
self.console.write("{!error!}Failed to connect to %s:%s!" % (host, port))
|
||||||
|
@ -54,3 +64,5 @@ class Command(BaseCommand):
|
||||||
d.addCallback(on_connect)
|
d.addCallback(on_connect)
|
||||||
d.addErrback(on_connect_fail)
|
d.addErrback(on_connect_fail)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
client.disconnect().addCallback(on_disconnect)
|
||||||
|
|
|
@ -140,6 +140,8 @@ class ConsoleUI(component.Component):
|
||||||
# Load all the commands
|
# Load all the commands
|
||||||
self._commands = load_commands(os.path.join(UI_PATH, 'commands'))
|
self._commands = load_commands(os.path.join(UI_PATH, 'commands'))
|
||||||
|
|
||||||
|
client.set_disconnect_callback(self.on_client_disconnect)
|
||||||
|
|
||||||
# Set the interactive flag to indicate where we should print the output
|
# Set the interactive flag to indicate where we should print the output
|
||||||
self.interactive = True
|
self.interactive = True
|
||||||
if args:
|
if args:
|
||||||
|
@ -166,7 +168,8 @@ class ConsoleUI(component.Component):
|
||||||
# any of the commands.
|
# any of the commands.
|
||||||
self.started_deferred.addCallback(on_started)
|
self.started_deferred.addCallback(on_started)
|
||||||
|
|
||||||
client.connect().addCallback(on_connect)
|
d = client.connect()
|
||||||
|
d.addCallback(on_connect)
|
||||||
|
|
||||||
self.coreconfig = CoreConfig()
|
self.coreconfig = CoreConfig()
|
||||||
if self.interactive:
|
if self.interactive:
|
||||||
|
@ -397,3 +400,6 @@ class ConsoleUI(component.Component):
|
||||||
for index, (tid, name) in enumerate(self.torrents):
|
for index, (tid, name) in enumerate(self.torrents):
|
||||||
if torrent_id == tid:
|
if torrent_id == tid:
|
||||||
del self.torrents[index]
|
del self.torrents[index]
|
||||||
|
|
||||||
|
def on_client_disconnect(self):
|
||||||
|
component.stop()
|
||||||
|
|
Loading…
Reference in New Issue