mirror of
https://git.deluge-torrent.org/deluge
synced 2025-04-20 03:24:54 +00:00
'Hack' in plugin support. This is totally wrong, but it sort of works.
This commit is contained in:
parent
7cd0ba0a6c
commit
78e225526c
5 changed files with 166 additions and 3 deletions
|
@ -50,10 +50,12 @@ else: dbus_imported = True
|
|||
|
||||
import gobject
|
||||
import deluge.libtorrent as lt
|
||||
import pkg_resources
|
||||
|
||||
from deluge.config import Config
|
||||
import deluge.common
|
||||
from deluge.core.torrentmanager import TorrentManager
|
||||
from deluge.core.pluginmanager import PluginManager
|
||||
|
||||
# Get the logger
|
||||
log = logging.getLogger("deluge")
|
||||
|
@ -87,7 +89,10 @@ class Core(dbus.service.Object):
|
|||
|
||||
# Start the TorrentManager
|
||||
self.torrents = TorrentManager(self.session)
|
||||
|
||||
|
||||
# Load plugins
|
||||
self.plugins = PluginManager()
|
||||
|
||||
log.debug("Starting main loop..")
|
||||
self.loop = gobject.MainLoop()
|
||||
self.loop.run()
|
||||
|
|
63
deluge/core/pluginmanager.py
Normal file
63
deluge/core/pluginmanager.py
Normal file
|
@ -0,0 +1,63 @@
|
|||
#
|
||||
# pluginmanager.py
|
||||
#
|
||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@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 2 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.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
|
||||
import logging
|
||||
import os.path
|
||||
|
||||
import pkg_resources
|
||||
|
||||
# Get the logger
|
||||
log = logging.getLogger("deluge")
|
||||
|
||||
class PluginManager:
|
||||
def __init__(self):
|
||||
# This will load any .eggs in the plugins folder inside the main
|
||||
# deluge egg.. Need to scan the local plugin folder too.
|
||||
|
||||
plugin_dir = os.path.join(os.path.dirname(__file__), "..", "plugins")
|
||||
|
||||
pkg_resources.working_set.add_entry(plugin_dir)
|
||||
pkg_env = pkg_resources.Environment([plugin_dir])
|
||||
|
||||
self.plugins = {}
|
||||
for name in pkg_env:
|
||||
egg = pkg_env[name][0]
|
||||
egg.activate()
|
||||
modules = []
|
||||
for name in egg.get_entry_map("deluge.plugin"):
|
||||
entry_point = egg.get_entry_info("deluge.plugin", name)
|
||||
cls = entry_point.load()
|
||||
instance = cls()
|
||||
self.plugins[name] = instance
|
||||
|
||||
log.info("Plugins loaded: %s", self.plugins)
|
39
deluge/plugins/queue/queue/__init__.py
Normal file
39
deluge/plugins/queue/queue/__init__.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
#
|
||||
# __init__.py
|
||||
#
|
||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@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 2 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.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
|
||||
class QueuePlugin:
|
||||
def __init__(self):
|
||||
print "queue plugin init!"
|
||||
|
||||
def test(self):
|
||||
print "queue plugin test!"
|
49
deluge/plugins/queue/setup.py
Normal file
49
deluge/plugins/queue/setup.py
Normal file
|
@ -0,0 +1,49 @@
|
|||
# setup.py
|
||||
#
|
||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program 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 this program. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
|
||||
"""
|
||||
Allow torrents to be queued in a specific order
|
||||
"""
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
__author__ = "Andrew Resch"
|
||||
|
||||
setup(
|
||||
name="Queue",
|
||||
version="1.0",
|
||||
description=__doc__,
|
||||
author=__author__,
|
||||
packages=["queue"],
|
||||
entry_points="""
|
||||
[deluge.plugin]
|
||||
Queue = queue:QueuePlugin
|
||||
"""
|
||||
)
|
11
setup.py
11
setup.py
|
@ -34,6 +34,7 @@ ez_setup.use_setuptools()
|
|||
from setuptools import setup, find_packages, Extension
|
||||
import platform
|
||||
import glob
|
||||
import os
|
||||
|
||||
python_version = platform.python_version()[0:3]
|
||||
|
||||
|
@ -83,6 +84,11 @@ libtorrent = Extension(
|
|||
sources = _sources
|
||||
)
|
||||
|
||||
# Build the plugin eggs
|
||||
for path in glob.glob('deluge/plugins/*'):
|
||||
print path + "/setup.py"
|
||||
os.system("cd " + path + "&& python setup.py bdist_egg -d ..")
|
||||
|
||||
# Main setup
|
||||
|
||||
setup(
|
||||
|
@ -100,11 +106,12 @@ setup(
|
|||
include_package_data = True,
|
||||
package_data = {"deluge": ["ui/gtkui/glade/*.glade",
|
||||
"data/pixmaps/*.png",
|
||||
"ui/gtkui/po/*.po?"
|
||||
"ui/gtkui/po/*.po?",
|
||||
"plugins/*.egg",
|
||||
]},
|
||||
ext_package = "deluge",
|
||||
ext_modules = [libtorrent],
|
||||
packages = find_packages(),
|
||||
packages = find_packages(exclude=["plugins"]),
|
||||
entry_points = """
|
||||
[console_scripts]
|
||||
deluge = deluge.main:main
|
||||
|
|
Loading…
Add table
Reference in a new issue