From 622080de50ba5dc6247206244290438f80c66360 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Fri, 30 Nov 2007 06:50:48 +0000 Subject: [PATCH] Fix signalreceiver to work when connected to a remote daemon. --- deluge/ui/gtkui/signals.py | 6 +++++- deluge/ui/signalreceiver.py | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/deluge/ui/gtkui/signals.py b/deluge/ui/gtkui/signals.py index a648710c5..9f8b948f3 100644 --- a/deluge/ui/gtkui/signals.py +++ b/deluge/ui/gtkui/signals.py @@ -32,6 +32,7 @@ # statement from all source files in the program, then also delete it here. import deluge.ui.component as component +import deluge.ui.client as client from deluge.ui.signalreceiver import SignalReceiver from deluge.log import LOG as log @@ -40,7 +41,10 @@ class Signals(component.Component): component.Component.__init__(self, "Signals") def start(self): - self.receiver = SignalReceiver(6667) + remote = False + if not client.is_localhost(): + remote = True + self.receiver = SignalReceiver(6667, remote) self.receiver.start() self.receiver.connect_to_signal("torrent_added", self.torrent_added_signal) diff --git a/deluge/ui/signalreceiver.py b/deluge/ui/signalreceiver.py index 1141d9019..faeacbcc2 100644 --- a/deluge/ui/signalreceiver.py +++ b/deluge/ui/signalreceiver.py @@ -49,7 +49,7 @@ class SignalReceiver( ThreadingMixIn, SimpleXMLRPCServer.SimpleXMLRPCServer): - def __init__(self, port): + def __init__(self, port, remote=False): log.debug("SignalReceiver init..") gobject.threads_init() threading.Thread.__init__(self) @@ -61,10 +61,14 @@ class SignalReceiver( # Daemonize the thread so it exits when the main program does self.setDaemon(True) + host = "localhost" + if remote == True: + host = "" + # Setup the xmlrpc server try: SimpleXMLRPCServer.SimpleXMLRPCServer.__init__( - self, ("localhost", port), logRequests=False, allow_none=True) + self, (host, port), logRequests=False, allow_none=True) except: log.info("SignalReceiver already running or port not available..") sys.exit(0)