From 885ca2c899964a7e3dfc68205a96b9475b820172 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Sun, 10 Feb 2008 12:02:57 +0000 Subject: [PATCH] Two new commands 'halt' and 'connect'. --- deluge/ui/null/deluge_shell.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/deluge/ui/null/deluge_shell.py b/deluge/ui/null/deluge_shell.py index e59b0d2bb..1e2e09199 100755 --- a/deluge/ui/null/deluge_shell.py +++ b/deluge/ui/null/deluge_shell.py @@ -268,6 +268,35 @@ class CommandRemove(Command): def help(self): print "Remove a torrent" +class CommandHalt(Command): + def execute(self, cmd): + client.shutdown() + + def help(self): + print "Shutdown the deluge server." + +class CommandConnect(Command): + def execute(self, cmd): + host = 'localhost' + port = 58846 + if len(cmd) > 1: + host = cmd[1] + if len(cmd) > 2: + port = int(cmd[2]) + + if host[:7] != "http://": + host = "http://" + host + + client.set_core_uri("%s:%d" % (host, port)) + + def usage(self): + print "Usage: connect [ []]" + print " 'localhost' is the default server. 58846 is the default port." + print "" + + def help(self): + print "Connect to a new deluge server." + commands = { 'add' : CommandAdd(), 'configs' : CommandConfig(), @@ -279,6 +308,8 @@ commands = { 'resume' : CommandResume(), 'rm' : CommandRemove(), 'del' : CommandRemove(), + 'halt' : CommandHalt(), + 'connect' : CommandConnect(), } logging.disable(logging.ERROR)