From 5ad7c60b656a748467966bfb701b5f3dc7087454 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Wed, 4 Feb 2009 06:27:40 +0000 Subject: [PATCH] Remove signalmanager --- deluge/core/core.py | 2 - deluge/core/preferencesmanager.py | 1 - deluge/core/signalmanager.py | 109 ------------------------------ deluge/core/torrent.py | 2 - deluge/core/torrentmanager.py | 2 - 5 files changed, 116 deletions(-) delete mode 100644 deluge/core/signalmanager.py diff --git a/deluge/core/core.py b/deluge/core/core.py index d9807484d..30eb6961b 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -48,7 +48,6 @@ from deluge.event import * from deluge.core.torrentmanager import TorrentManager from deluge.core.pluginmanager import PluginManager from deluge.core.alertmanager import AlertManager -from deluge.core.signalmanager import SignalManager from deluge.core.filtermanager import FilterManager from deluge.core.preferencesmanager import PreferencesManager from deluge.core.autoadd import AutoAdd @@ -113,7 +112,6 @@ class Core(component.Component): # Create the components self.preferencesmanager = PreferencesManager() self.alertmanager = AlertManager(self.session) - self.signalmanager = SignalManager() self.pluginmanager = PluginManager(self) self.torrentmanager = TorrentManager(self.session, self.alertmanager) self.filtermanager = FilterManager(self) diff --git a/deluge/core/preferencesmanager.py b/deluge/core/preferencesmanager.py index 118e5bf06..3657ed780 100644 --- a/deluge/core/preferencesmanager.py +++ b/deluge/core/preferencesmanager.py @@ -143,7 +143,6 @@ class PreferencesManager(component.Component): self.core = component.get("Core") self.session = component.get("Core").session self.settings = component.get("Core").settings - self.signals = component.get("SignalManager") # Register set functions in the Config self.config.register_set_function("torrentfiles_location", diff --git a/deluge/core/signalmanager.py b/deluge/core/signalmanager.py deleted file mode 100644 index 56920cdde..000000000 --- a/deluge/core/signalmanager.py +++ /dev/null @@ -1,109 +0,0 @@ -# -# signalmanager.py -# -# Copyright (C) 2007, 2008 Andrew Resch -# -# Deluge is free software. -# -# You may redistribute it and/or modify it under the terms of the -# GNU General Public License, as published by the Free Software -# Foundation; either version 3 of the License, or (at your option) -# any later version. -# -# deluge is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with deluge. If not, write to: -# The Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor -# Boston, MA 02110-1301, USA. -# - - -import deluge.xmlrpclib as xmlrpclib -import socket -import struct - -from twisted.internet import reactor -from twisted.internet.task import LoopingCall - -import deluge.component as component -from deluge.log import LOG as log - -class Transport(xmlrpclib.Transport): - def make_connection(self, host): - # create a HTTP connection object from a host descriptor - import httplib - host, extra_headers, x509 = self.get_host_info(host) - h = httplib.HTTP(host) - h._conn.connect() - h._conn.sock.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, - struct.pack('ii', 1, 0)) - return h - -class SignalManager(component.Component): - def __init__(self): - component.Component.__init__(self, "SignalManager") - self.clients = {} - self.handlers = {} - - def shutdown(self): - self.clients = {} - self.handlers = {} - - def register_handler(self, signal, handler): - """Registers a handler for signals""" - if signal not in self.handler.keys(): - self.handler[signal] = [] - - self.handler[signal].append(handler) - log.debug("Registered signal handler for %s", signal) - - def deregister_handler(self, handler): - """De-registers the 'handler' function from all signal types.""" - # Iterate through all handlers and remove 'handler' where found - for (key, value) in self.handlers: - if handler in value: - value.remove(handler) - - def deregister_client(self, address): - """Deregisters a client""" - log.debug("Deregistering %s as a signal reciever..", address) - for client in self.clients.keys(): - if client.split("//")[1].split(":")[0] == address: - del self.clients[client] - break - - def register_client(self, address, port): - """Registers a client to emit signals to.""" - uri = "http://" + str(address) + ":" + str(port) - log.debug("Registering %s as a signal reciever..", uri) - self.clients[uri] = xmlrpclib.ServerProxy(uri, transport=Transport()) - - def emit(self, signal, *data): - # Run the handlers - if signal in self.handlers.keys(): - for handler in self.handlers[signal]: - handler(*data) - - for uri in self.clients: - # reactor.callLater(0, self._emit, uri, signal, 1, *data) - #XXX: Need to fix this for the new signal sending - pass - - def _emit(self, uri, signal, count, *data): - if uri not in self.clients: - return - client = self.clients[uri] - try: - client.emit_event_signal(signal, *data) - except (socket.error, Exception), e: - log.warning("Unable to emit signal to client %s: %s (%d)", client, e, count) - if count < 30: - reactor.callLater(1, self._emit, uri, signal, count + 1, *data) - else: - log.info("Removing %s because it couldn't be reached..", uri) - del self.clients[uri] diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 715d042d7..13b225186 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -108,8 +108,6 @@ class Torrent: # Get the core config self.config = ConfigManager("core.conf") - self.signals = component.get("SignalManager") - # Set the libtorrent handle self.handle = handle # Set the torrent_id for this torrent diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 1f14c237a..8a75a7a20 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -171,8 +171,6 @@ class TorrentManager(component.Component): # Get the pluginmanager reference self.plugins = component.get("CorePluginManager") - self.signals = component.get("SignalManager") - # Run the old state upgrader before loading state deluge.core.oldstateupgrader.OldStateUpgrader()