mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
Add the ability to add plugins from the plugins preference page (from
.eggs) Add a rescan for plugins button to rescan the plugin folders
This commit is contained in:
parent
af0bd07d3e
commit
a27b0c6329
5 changed files with 914 additions and 636 deletions
|
@ -680,6 +680,21 @@ class Core(
|
||||||
if add_to_session:
|
if add_to_session:
|
||||||
self.export_add_torrent_file(os.path.split(target)[1], open(target, "rb").read(), None)
|
self.export_add_torrent_file(os.path.split(target)[1], open(target, "rb").read(), None)
|
||||||
|
|
||||||
|
def export_upload_plugin(self, filename, plugin_data):
|
||||||
|
"""This method is used to upload new plugins to the daemon. It is used
|
||||||
|
when connecting to the daemon remotely and installing a new plugin on
|
||||||
|
the client side. 'plugin_data' is a xmlrpc.Binary object of the file data,
|
||||||
|
ie, plugin_file.read()"""
|
||||||
|
|
||||||
|
f = open(os.path.join(self.config["config_location"], "plugins", filename), "wb")
|
||||||
|
f.write(plugin_data.data)
|
||||||
|
f.close()
|
||||||
|
component.get("PluginManager").scan_for_plugins()
|
||||||
|
|
||||||
|
def export_rescan_plugins(self):
|
||||||
|
"""Rescans the plugin folders for new plugins"""
|
||||||
|
component.get("PluginManager").scan_for_plugins()
|
||||||
|
|
||||||
## Queueing functions ##
|
## Queueing functions ##
|
||||||
def export_queue_top(self, torrent_ids):
|
def export_queue_top(self, torrent_ids):
|
||||||
log.debug("Attempting to queue %s to top", torrent_ids)
|
log.debug("Attempting to queue %s to top", torrent_ids)
|
||||||
|
|
|
@ -49,6 +49,10 @@ class PluginManagerBase:
|
||||||
|
|
||||||
self.config = deluge.configmanager.ConfigManager(config_file)
|
self.config = deluge.configmanager.ConfigManager(config_file)
|
||||||
|
|
||||||
|
# Create the plugins folder if it doesn't exist
|
||||||
|
if not os.path.exists(os.path.join(deluge.configmanager.get_config_dir(), "plugins")):
|
||||||
|
os.mkdir(os.path.join(deluge.configmanager.get_config_dir(), "plugins"))
|
||||||
|
|
||||||
# This is the entry we want to load..
|
# This is the entry we want to load..
|
||||||
self.entry_name = entry_name
|
self.entry_name = entry_name
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,8 @@ class BaseClient(object):
|
||||||
"set_torrent_prioritize_first_last", "set_torrent_auto_managed",
|
"set_torrent_prioritize_first_last", "set_torrent_auto_managed",
|
||||||
"set_torrent_stop_ratio", "set_torrent_stop_at_ratio",
|
"set_torrent_stop_ratio", "set_torrent_stop_at_ratio",
|
||||||
"set_torrent_remove_at_ratio", "set_torrent_move_on_completed",
|
"set_torrent_remove_at_ratio", "set_torrent_move_on_completed",
|
||||||
"set_torrent_move_on_completed_path", "add_torrent_magnets", "create_torrent"]
|
"set_torrent_move_on_completed_path", "add_torrent_magnets",
|
||||||
|
"create_torrent", "upload_plugin", "rescan_plugins"]
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.core = _core
|
self.core = _core
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -94,7 +94,9 @@ class Preferences(component.Component):
|
||||||
"on_button_apply_clicked": self.on_button_apply_clicked,
|
"on_button_apply_clicked": self.on_button_apply_clicked,
|
||||||
"on_button_cancel_clicked": self.on_button_cancel_clicked,
|
"on_button_cancel_clicked": self.on_button_cancel_clicked,
|
||||||
"on_toggle": self.on_toggle,
|
"on_toggle": self.on_toggle,
|
||||||
"on_test_port_clicked": self.on_test_port_clicked
|
"on_test_port_clicked": self.on_test_port_clicked,
|
||||||
|
"on_button_plugin_install_clicked": self._on_button_plugin_install_clicked,
|
||||||
|
"on_button_rescan_plugins_clicked": self._on_button_rescan_plugins_clicked
|
||||||
})
|
})
|
||||||
|
|
||||||
# These get updated by requests done to the core
|
# These get updated by requests done to the core
|
||||||
|
@ -800,4 +802,55 @@ class Preferences(component.Component):
|
||||||
|
|
||||||
def on_plugin_selection_changed(self, treeselection):
|
def on_plugin_selection_changed(self, treeselection):
|
||||||
log.debug("on_plugin_selection_changed")
|
log.debug("on_plugin_selection_changed")
|
||||||
|
|
||||||
|
def _on_button_plugin_install_clicked(self, widget):
|
||||||
|
log.debug("_on_button_plugin_install_clicked")
|
||||||
|
chooser = gtk.FileChooserDialog(_("Select the Plugin"),
|
||||||
|
self.pref_dialog,
|
||||||
|
gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||||
|
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN,
|
||||||
|
gtk.RESPONSE_OK))
|
||||||
|
|
||||||
|
chooser.set_transient_for(self.pref_dialog)
|
||||||
|
chooser.set_select_multiple(False)
|
||||||
|
chooser.set_property("skip-taskbar-hint", True)
|
||||||
|
|
||||||
|
file_filter = gtk.FileFilter()
|
||||||
|
file_filter.set_name(_("Plugin Eggs"))
|
||||||
|
file_filter.add_pattern("*." + "egg")
|
||||||
|
chooser.add_filter(file_filter)
|
||||||
|
|
||||||
|
# Run the dialog
|
||||||
|
response = chooser.run()
|
||||||
|
|
||||||
|
if response == gtk.RESPONSE_OK:
|
||||||
|
filepath = chooser.get_filename()
|
||||||
|
else:
|
||||||
|
chooser.destroy()
|
||||||
|
return
|
||||||
|
|
||||||
|
import shutil
|
||||||
|
import os.path
|
||||||
|
filename = os.path.split(filepath)[1]
|
||||||
|
shutil.copyfile(
|
||||||
|
filepath,
|
||||||
|
os.path.join(self.gtkui_config["config_location"], "plugins", filename))
|
||||||
|
|
||||||
|
component.get("PluginManager").scan_for_plugins()
|
||||||
|
|
||||||
|
if not client.is_localhost():
|
||||||
|
# We need to send this plugin to the daemon
|
||||||
|
client.upload_plugin(
|
||||||
|
filename,
|
||||||
|
xmlrpclib.Binary(open(filepath, "rb").read()))
|
||||||
|
|
||||||
|
client.rescan_plugins()
|
||||||
|
chooser.destroy()
|
||||||
|
# We need to re-show the preferences dialog to show the new plugins
|
||||||
|
self.show()
|
||||||
|
|
||||||
|
def _on_button_rescan_plugins_clicked(self, widget):
|
||||||
|
component.get("PluginManager").scan_for_plugins()
|
||||||
|
client.rescan_plugins()
|
||||||
|
self.show()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue