begin messing about with the plugin manager

This commit is contained in:
Damien Churchill 2009-04-16 22:03:50 +00:00
parent 74ac41e686
commit 8fef414054
3 changed files with 60 additions and 0 deletions

View File

@ -81,6 +81,7 @@ class JSON(resource.Resource, component.Component):
component.Component.__init__(self, "JSON") component.Component.__init__(self, "JSON")
self._remote_methods = [] self._remote_methods = []
self._local_methods = {} self._local_methods = {}
client.disconnect_callback = self._on_client_disconnect
def connect(self, host="localhost", port=58846, username="", password=""): def connect(self, host="localhost", port=58846, username="", password=""):
""" """
@ -105,9 +106,13 @@ class JSON(resource.Resource, component.Component):
""" """
d = client.daemon.get_method_list() d = client.daemon.get_method_list()
d.addCallback(on_get_methods) d.addCallback(on_get_methods)
component.get("PluginManager").start()
_d.addCallback(on_client_connected) _d.addCallback(on_client_connected)
return d return d
def _on_client_disconnect(self, *args):
component.get("PluginManager").stop()
def _exec_local(self, method, params): def _exec_local(self, method, params):
""" """
Handles executing all local methods. Handles executing all local methods.

View File

@ -0,0 +1,51 @@
#
# pluginmanager.py
#
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
#
# 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 logging
from deluge.component import Component
from deluge.pluginmanagerbase import PluginManagerBase
from deluge.ui.client import client
from deluge.configmanager import ConfigManager
log = logging.getLogger(__name__)
class PluginManager(PluginManagerBase, Component):
def __init__(self):
Component.__init__(self, "PluginManager")
self.config = ConfigManager("web.conf")
PluginManagerBase.__init__(self, "web.conf", "deluge.plugin.web")
def start(self):
"""Start up the plugin manager"""
# Update the enabled plugins from the core
d = client.core.get_enabled_plugins()
d.addCallback(self._on_get_enabled_plugins)
def stop(self):
self.disable_plugins()
def update(self):
pass

View File

@ -46,6 +46,7 @@ from deluge.ui import common as uicommon
from deluge.ui.tracker_icons import TrackerIcons from deluge.ui.tracker_icons import TrackerIcons
from deluge.ui.web.common import Template from deluge.ui.web.common import Template
from deluge.ui.web.json_api import JSON, WebApi from deluge.ui.web.json_api import JSON, WebApi
from deluge.ui.web.pluginmanager import PluginManager
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
# Initialize gettext # Initialize gettext
@ -304,6 +305,9 @@ class DelugeWeb(component.Component):
return 1 return 1
SetConsoleCtrlHandler(win_handler) SetConsoleCtrlHandler(win_handler)
# Initalize the plugins
self.plugins = PluginManager()
def start(self): def start(self):
log.info("%s %s.", _("Starting server in PID"), os.getpid()) log.info("%s %s.", _("Starting server in PID"), os.getpid())
reactor.listenTCP(self.port, self.site) reactor.listenTCP(self.port, self.site)