Fix signalreceiver to work when connected to a remote daemon.
This commit is contained in:
parent
6953e280ad
commit
622080de50
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue