diff --git a/deluge/plugins/example/example/__init__.py b/deluge/plugins/example/example/__init__.py deleted file mode 100644 index aa7562bdc..000000000 --- a/deluge/plugins/example/example/__init__.py +++ /dev/null @@ -1,54 +0,0 @@ -# -# __init__.py -# -# Copyright (C) 2009 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. -# -# 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. -# -# - -from deluge.plugins.init import PluginInitBase - -class CorePlugin(PluginInitBase): - def __init__(self, plugin_name): - from core import Core as _plugin_cls - self._plugin_cls = _plugin_cls - super(CorePlugin, self).__init__(plugin_name) - -class GtkUIPlugin(PluginInitBase): - def __init__(self, plugin_name): - from gtkui import GtkUI as _plugin_cls - self._plugin_cls = _plugin_cls - super(GtkUIPlugin, self).__init__(plugin_name) - -class WebUIPlugin(PluginInitBase): - def __init__(self, plugin_name): - from webui import WebUI as _plugin_cls - self._plugin_cls = _plugin_cls - super(WebUIPlugin, self).__init__(plugin_name) diff --git a/deluge/plugins/example/example/common.py b/deluge/plugins/example/example/common.py deleted file mode 100644 index 71701676d..000000000 --- a/deluge/plugins/example/example/common.py +++ /dev/null @@ -1,40 +0,0 @@ -# -# common.py -# -# Copyright (C) 2009 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. -# -# 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 pkg_resources -import os.path - -def get_resource(filename): - return pkg_resources.resource_filename("example", os.path.join("data", filename)) diff --git a/deluge/plugins/example/example/core.py b/deluge/plugins/example/example/core.py deleted file mode 100644 index 2d78d1bf9..000000000 --- a/deluge/plugins/example/example/core.py +++ /dev/null @@ -1,55 +0,0 @@ -# -# core.py -# -# Copyright (C) 2009 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. -# -# 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. -# -# - -from deluge.log import LOG as log -from deluge.plugins.pluginbase import CorePluginBase -import deluge.component as component -import deluge.configmanager -from deluge.core.rpcserver import export - -class Core(CorePluginBase): - def enable(self): - log.debug("Example core plugin enabled!") - - def disable(self): - log.debug("Example core plugin disabled!") - - def update(self): - pass - - ### Exported RPC methods ### - @export() - def example_method(self): - pass diff --git a/deluge/plugins/example/example/data/example.js b/deluge/plugins/example/example/data/example.js deleted file mode 100644 index 98fe87672..000000000 --- a/deluge/plugins/example/example/data/example.js +++ /dev/null @@ -1,51 +0,0 @@ -/* -Script: example.js - The client-side javascript code for the Example plugin. - -Copyright: - (C) Damien Churchill 2009 - 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 3, 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. -*/ - -ExamplePlugin = Ext.extend(Deluge.Plugin, { - constructor: function(config) { - config = Ext.apply({ - name: "Example" - }, config); - ExamplePlugin.superclass.constructor.call(this, config); - }, - - onDisable: function() { - Deluge.Preferences.removePage(this.prefsPage); - }, - - onEnable: function() { - this.prefsPage = new ExamplePreferencesPanel(); - this.prefsPage = Deluge.Preferences.addPage(this.prefsPage); - } -}); -new ExamplePlugin(); \ No newline at end of file diff --git a/deluge/plugins/example/example/gtkui.py b/deluge/plugins/example/example/gtkui.py deleted file mode 100644 index 39f1b77a9..000000000 --- a/deluge/plugins/example/example/gtkui.py +++ /dev/null @@ -1,48 +0,0 @@ -# -# gtkui.py -# -# Copyright (C) 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. -# -# 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 gtk - -from deluge.log import LOG as log -from deluge.ui.client import client -from deluge.plugins.pluginbase import GtkPluginBase -import deluge.component as component -import deluge.common - -class GtkUI(GtkPluginBase): - def enable(self): - pass - def disable(self): - pass diff --git a/deluge/plugins/example/example/webui.py b/deluge/plugins/example/example/webui.py deleted file mode 100644 index df2efadd5..000000000 --- a/deluge/plugins/example/example/webui.py +++ /dev/null @@ -1,54 +0,0 @@ -# -# webui.py -# -# Copyright (C) 2009 Martijn Voncken -# -# 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. -# -# 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. -# -# - -from deluge.log import LOG as log -from deluge.ui.client import client -from deluge import component -from deluge.plugins.pluginbase import WebPluginBase - -from common import get_resource - -class WebUI(WebPluginBase): - - scripts = [get_resource("example.js")] - - # The enable and disable methods are not scrictly required on the WebUI - # plugins. They are only here if you need to register images/stylesheets - # with the webserver. - def enable(self): - log.debug("Example Web plugin enabled!") - - def disable(self): - log.debug("Example Web plugin disabled!") diff --git a/deluge/plugins/example/setup.py b/deluge/plugins/example/setup.py deleted file mode 100644 index c666efc18..000000000 --- a/deluge/plugins/example/setup.py +++ /dev/null @@ -1,67 +0,0 @@ -# -# setup.py -# -# Copyright (C) 2008 Andrew Resch -# -# 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 3, 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. -# -# - -from setuptools import setup - -__plugin_name__ = "Example" -__author__ = "Andrew Resch" -__author_email__ = "andrewresch@gmail.com" -__version__ = "1.2" -__url__ = "http://deluge-torrent.org" -__license__ = "GPLv3" -__description__ = "Example plugin" -__long_description__ = __description__ -__pkg_data__ = {__plugin_name__.lower(): []} - -setup( - name=__plugin_name__, - version=__version__, - description=__description__, - author=__author__, - author_email=__author_email__, - url=__url__, - license=__license__, - long_description=__long_description__, - - packages=[__plugin_name__.lower()], - package_data = __pkg_data__, - - entry_points=""" - [deluge.plugin.core] - %s = %s:CorePlugin - [deluge.plugin.gtkui] - %s = %s:GtkUIPlugin - [deluge.plugin.webui] - %s = %s:WebUIPlugin - """ % ((__plugin_name__, __plugin_name__.lower())*3) -) diff --git a/deluge/plugins/feeder/feeder/__init__.py b/deluge/plugins/feeder/feeder/__init__.py deleted file mode 100644 index 994412471..000000000 --- a/deluge/plugins/feeder/feeder/__init__.py +++ /dev/null @@ -1,55 +0,0 @@ -# -# feeder/__init__.py -# -# Copyright (C) 2007-2009 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. -# -# 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. -# -# - -from deluge.plugins.init import PluginInitBase - -class CorePlugin(PluginInitBase): - def __init__(self, plugin_name): - from core import Core as _plugin_cls - self._plugin_cls = _plugin_cls - super(CorePlugin, self).__init__(plugin_name) - -class GtkUIPlugin(PluginInitBase): - def __init__(self, plugin_name): - from gtkui import GtkUI as _plugin_cls - self._plugin_cls = _plugin_cls - super(GtkUIPlugin, self).__init__(plugin_name) - -class WebUIPlugin(PluginInitBase): - def __init__(self, plugin_name): - from webui import WebUI as _plugin_cls - self._plugin_cls = _plugin_cls - super(WebUIPlugin, self).__init__(plugin_name) diff --git a/deluge/plugins/feeder/feeder/core.py b/deluge/plugins/feeder/feeder/core.py deleted file mode 100644 index 0324556e3..000000000 --- a/deluge/plugins/feeder/feeder/core.py +++ /dev/null @@ -1,432 +0,0 @@ -# -# core.py -# -# Copyright (C) 2008-2009 Fredrik Eriksson -# Copyright (C) 2009 David Mohr -# -# Basic plugin template created by: -# Copyright (C) 2008 Martijn Voncken -# Copyright (C) 2007-2009 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. -# -# 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 feedparser # for parsing rss feeds -import threading # for threaded updates -import re # for regular expressions -from twisted.internet.task import LoopingCall - -from deluge.log import LOG as log -from deluge.plugins.pluginbase import CorePluginBase -import deluge.component as component -import deluge.configmanager -from deluge.core.rpcserver import export - -DEFAULT_PREFS = { - "feeds": {}, - "filters": {}, - "updatetime": 15, - "history": [] -} - -# Helper classes - -class Feed: - """ - Class for the Feed object (containging feed configurations) - """ - def __init__(self): - self.url = "" - self.cookies = {} - self.updatetime = 15 - - def get_config(self): - try: - tmp = self.cookies - except Exception, e: - log.debug("Old feed without cookies... updating") - self.cookies = {} - return {'url': self.url, 'updatetime': self.updatetime, 'cookies': self.cookies} - - def set_config(self, config): - self.url = config['url'] - self.updatetime = config['updatetime'] - self.cookies = config['cookies'] - - -class Filter: - """ - Class for the Filter object (containing filter configurations) - """ - - def __init__(self): - self.regex = "" - self.feeds = [] #TODO activate filter per feed - self.all_feeds = True - self.active = True - - # by default, set the configuration to match - # the per-torrent settings in deluge - def_conf = component.get("Core").get_config() - self.max_download_speed = def_conf['max_download_speed_per_torrent'] - self.max_upload_speed = def_conf['max_upload_speed_per_torrent'] - self.max_connections = def_conf['max_connections_per_torrent'] - self.max_upload_slots = def_conf['max_upload_slots_per_torrent'] - self.prioritize_first_last_pieces = def_conf['prioritize_first_last_pieces'] - self.auto_managed = def_conf['auto_managed'] - self.download_location = def_conf['download_location'] - - self.stop_at_ratio = def_conf['stop_seed_at_ratio'] - self.stop_ratio = def_conf['stop_seed_ratio'] - self.remove_at_ratio = def_conf['remove_seed_at_ratio'] - - def get_config(self): - def_conf = component.get("Core").get_config() - - try: - tmp = self.active - except Exception, e: - log.debug("Old filter detected (pre 0.3), updating...") - self.active = True - - try: - tmp = self.stop_at_ratio - tmp = self.stop_ratio - tmp = self.remove_at_ratio - except: - log.debug("Old filter detected (pre 0.4), updating...") - self.stop_at_ratio = def_conf['stop_seed_at_ratio'] - self.stop_ratio = def_conf['stop_seed_ratio'] - self.remove_at_ratio = def_conf['remove_seed_at_ratio'] - - conf = { - 'regex': self.regex, - 'feeds': self.feeds, - 'all_feeds': self.all_feeds, - 'active' : self.active, - 'max_download_speed': self.max_download_speed, - 'max_upload_speed': self.max_upload_speed, - 'max_connections': self.max_connections, - 'max_upload_slots': self.max_upload_slots, - 'prioritize_first_last_pieces': self.prioritize_first_last_pieces, - 'auto_managed': self.auto_managed, - 'download_location':self.download_location, - 'remove_at_ratio':self.remove_at_ratio, - 'stop_ratio': self.stop_ratio, - 'stop_at_ratio': self.stop_at_ratio } - - return conf - - def set_config(self, conf): - self.regex = conf['regex'] - self.feeds = conf['feeds'] - self.all_feeds = conf['all_feeds'] - self.active = conf['active'] - self.max_download_speed = int(conf['max_download_speed']) - self.max_upload_speed = int(conf['max_upload_speed']) - self.max_connections = int(conf['max_connections']) - self.max_upload_slots = int(conf['max_upload_slots']) - self.prioritize_first_last_pieces = conf['prioritize_first_last_pieces'] - self.auto_managed = conf['auto_managed'] - self.download_location = conf['download_location'] - self.remove_at_ratio = conf['remove_at_ratio'] - self.stop_ratio = float(conf['stop_ratio']) - self.stop_at_ratio = conf['stop_at_ratio'] - - -class Core(CorePluginBase): - def enable(self): - self.config = deluge.configmanager.ConfigManager("feeder.conf", DEFAULT_PREFS) - self.feeds = {} - self.timers = {} - self.history = self.config['history'] - self.time = 0 - - # Setting default timer to configured update time - for feed in self.config['feeds']: - self.timers[feed] = LoopingCall(self.update_feed, feed) - self.timers[feed].start( self.config['feeds'][feed].updatetime * 60) - - - def disable(self): - self.config['history'] = self.history - self.config.save() - - - def update(self): - pass - - - -#=================Exported functions================== - - @export - def set_config(self, config): - """sets the config dictionary""" - for key in config.keys(): - self.config[key] = config[key] - self.config.save() - -####################Configuration Getters################## - - @export - def get_config(self): - """returns the config dictionary""" - return self.config.config - - @export - def get_feed_config(self, feedname): - """Returns configuration for a feed""" - return self.config['feeds'][feedname].get_config() - - @export - def get_filter_config(self, filtername): - """Returns a configuration for a filter""" - return self.config['filters'][filtername].get_config() - -####################Information Getters#################### - - @export - def get_feeds(self): - """Returns a list of the configured feeds""" - feeds = [] - for feedname in self.config['feeds']: - feeds.append(feedname) - feeds.sort(key=string.lower) - return feeds - - @export - def get_filters(self): - """Returns a list of all available filters""" - filters = [] - for filter in self.config['filters']: - filters.append(filter) - filters.sort(key=string.lower) - return filters - - @export - def get_items(self, feedname): - """Returns a dictionary with feedname:link""" - try: - items = {} - feed = self.feeds[feedname] - for entry in feed['entries']: - items[entry.title] = entry.link - except Exception, e: - items = {} - log.warning("Feed '%s' not loaded", feedname) - return items - - @export - def test_filter(self, regex): - filters = { "to_test":Filter() } - conf = filters["to_test"].get_config() - conf["regex"] = regex - filters["to_test"].set_config(conf) - hits = {} - for feed in self.feeds: - hits.update(self.run_filters(feed, filters, test=True)) - return hits - - @export - def add_feed(self, config): - """adds/updates a feed and, for whatever reason, sets the default timeout""" - - # save the feedname and remove it from the config - feedname = config['name'] - del config['name'] - - # check if the feed already exists and save config - try: - conf = self.config['feeds'][feedname].get_config() - del self.config['feeds'][feedname] - except Exception, e: - conf = {} - - # update configuration - for var in config: - conf[var] = config[var] - - # save as default update time - try: - self.config['updatetime'] = config['updatetime'] - except Exception, e: - log.warning("updatetime not set when adding feed %s", feedname) - - # Create the new feed - newfeed = Feed() - newfeed.set_config(conf) - - # Add a timer (with default timer for now, since we can't get ttl just yet)... - self.timers[feedname] = LoopingCall(self.update_feed, feedname) - - # Save the new feed - self.config['feeds'].update({feedname: newfeed }) - self.config.save() - - # Start the timeout, which will also update the new feed - self.timers[feedname].start(newfeed.updatetime * 60) - - @export - def remove_feed(self, feedname): - """Remove a feed""" - if self.feeds.has_key(feedname): # Check if we have the feed saved and remove it - del self.feeds[feedname] - if self.timers.has_key(feedname): # Check if we have a timer for this feed and remove it - self.timers[feedname].stop() - del self.timers[feedname] - if self.config['feeds'].has_key(feedname): # Check if we have the feed in the configuration and remove it - del self.config['feeds'][feedname] - self.config.save() - - @export - def add_filter(self, name): - """Adds a new filter to the configuration""" - if not self.config['filters'].has_key(name): # we don't want to add a filter that already exists - self.config['filters'][name] = Filter() - self.config.save() - - @export - def set_filter_config(self, filtername, conf): - """Changes the options for a filter""" - oldconf = self.config['filters'][filtername].get_config() - for item in conf: - oldconf[item] = conf[item] - - self.config['filters'][filtername].set_config(oldconf) - self.config.save() - for feed in self.config['feeds']: # we would like to check if the filter now matches something new - self.run_filters(feed) - - @export - def remove_filter(self, name): - """Removes a filter""" - if self.config['filters'].has_key(name): # Can't remove a filter that doesn't exists - del self.config['filters'][name] - self.config.save() - -#=================Internal functions================ - - def update_feed(self, feedname): - """Start a thread to update a single feed""" - threading.Thread( - target=self.update_feed_thread, - args=(self.on_feed_updated, feedname)).start() - - # Need to return true to not destoy timer... - return True - - def update_feed_thread(self, callback, feedname): - """updates a feed""" - feed = self.config['feeds'][feedname] - try: - self.feeds[feedname] = feedparser.parse(feed.url) - except Exception, e: - log.warning("Error parsing feed %s: %s", feedname, e) - else: - callback(feedname) - - def on_feed_updated(self, feedname): - """Run stuff when a feed has been updated""" - - # Not all feeds contain a ttl value, but if it does - # we would like to obey it - try: - if not self.feeds[feedname].ttl == self.config['feeds'][feedname].updatetime: - log.debug("feed '%s' request a ttl of %s, updating timer", feedname, self.feeds[feedname].ttl) - self.config['feeds'][feedname].updatetime = self.feeds[feedname].ttl - self.timers[feedname].stop() - self.timers[feedname].start(self.config['feeds'][feedname].updatetime * 60) - except Exception, e: - log.debug("feed '%s' has no ttl set, will use default timer", feedname) - - # Run filters on the feed - self.run_filters(feedname) - - def run_filters(self, feedname, filters={}, test=False): - """Test all available filters on the given feed""" - if not filters: - filters = self.config['filters'] - log.debug("will test filters %s", filters) - hits = {} - # Test every entry... - for entry in self.feeds[feedname]['entries']: - # ...and every filter - for filter in filters: - # We need to be able to run feeds saved before implementation of actiave/deactivate filter (pre 0.3) TODO - try: - if not filters[filter].active: - continue - except: - log.debug("old filter, will assume filter is activated") - - if filters[filter].regex == "": # we don't want a empty regex... - log.warning("Filter '%s' has not been configured, ignoring!", filter) - continue - - # if the filter isn't supposed to be run on this feed we don't want to run it... -# if filter.all_feeds or self.config['filters'][filter].feeds.has_element(feedname) : # ...apparently has_element doesn't work on arrays... TODO - if self.test_filter(entry, filters[filter].regex): - if test: - hits[entry.title] = entry.link - else: - opts = filters[filter].get_config() - #remove filter options that should not be passed on to the torrent. - del opts['regex'] - del opts['feeds'] - del opts['all_feeds'] - - # history patch from Darrell Enns, slightly modified :) - # check history to prevent multiple adds of the same torrent - log.debug("testing %s", entry.link) - if not entry.link in self.history: - self.add_torrent(entry.link, opts, self.feeds[feedname].cookies) - self.history.append(entry.link) - - #limit history to 50 entries - if len(self.history)>50: - self.history=self.history[-50:] - log.debug("wrapping history") - else: - log.debug("'%s' is in history, will not download", entry.link) - return hits - - - def test_filter(self, entry, filter): - """Tests a filter to a given rss entry""" - f = re.compile(filter, re.IGNORECASE) - if f.search(entry.title) or f.search(entry.link): - log.debug("RSS item '%s' matches filter '%s'", entry.title, filter) - return True - else: - return False - - def add_torrent(self, url, torrent_options, headers): - log.debug("Attempting to add torrent %s", url) - component.get("Core").add_torrent_url(url, torrent_options, headers) diff --git a/deluge/plugins/feeder/feeder/template/feeds.html b/deluge/plugins/feeder/feeder/template/feeds.html deleted file mode 100644 index c5c177235..000000000 --- a/deluge/plugins/feeder/feeder/template/feeds.html +++ /dev/null @@ -1,13 +0,0 @@ -$def with (entries, feedname) -$:render.header("things", '') -
-
-

Feed items for feed $feedname

-
    -$entries -
-
-back to config -
- -$:render.footer() diff --git a/deluge/plugins/feeder/feeder/template/filter_settings.html b/deluge/plugins/feeder/feeder/template/filter_settings.html deleted file mode 100644 index b2dcd3d42..000000000 --- a/deluge/plugins/feeder/feeder/template/filter_settings.html +++ /dev/null @@ -1,50 +0,0 @@ -$def with (filter_settings_form, filter) - - - - - Deluge:things - - - - - - - - - - - - - - -
-
-

Filter

- -$:(filter_settings_form.as_table(["regex", "active"])) -
- -

Speed

- -$:(filter_settings_form.as_table(["max_download_speed", "max_upload_speed", "max_upload_slots", "max_connections"])) -
- -

Seed options

- -$:(filter_settings_form.as_table(["stop_ratio", "stop_at_ratio", "remove_at_ratio"])) -
- -

Other options

- -$:(filter_settings_form.as_table(["prioritize_first_last_pieces", "auto_managed", "download_location"])) -
- - - -

Matches

-$:filter_settings_form.post_html() -
- - - diff --git a/deluge/plugins/feeder/feeder/template/filters.html b/deluge/plugins/feeder/feeder/template/filters.html deleted file mode 100644 index cf2187cd3..000000000 --- a/deluge/plugins/feeder/feeder/template/filters.html +++ /dev/null @@ -1,39 +0,0 @@ -$def with (filters, new_filter_form) -$:render.header("things", '') - - - -
- -
-

Filters

-
-
-
-
    - $filters -
-
- $:(new_filter_form.as_p(["name"])) - -
-

back to config -

-
-
- -
-
- - - -$:render.footer() diff --git a/deluge/plugins/feeder/feeder/webui.py b/deluge/plugins/feeder/feeder/webui.py deleted file mode 100644 index 4769155f3..000000000 --- a/deluge/plugins/feeder/feeder/webui.py +++ /dev/null @@ -1,277 +0,0 @@ -# -# webui.py -# -# Copyright (C) 2008 Fredrik Eriksson -# -# Basic plugin template created by: -# Copyright (C) 2008 Martijn Voncken -# 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. -# -# 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 - -import feedparser # for proccessing feed entries -import os -from deluge.log import LOG as log -from deluge.ui.client import sclient, aclient -from deluge.plugins.webuipluginbase import WebUIPluginBase -from deluge import component - -api = component.get("WebPluginApi") -forms = api.forms - -class feed_page: - "Class for showing feed items" - @api.deco.deluge_page - def GET(self, feedname): - entries = sclient.feeder_get_items(feedname) - items = "" - for item in entries: - items = """%(old)s - -
  • %(entry)s
  • -
    """ % { "old":items, "entry":item, "link":entries[item]} - return api.render.feeder.feeds(items, feedname) - -class filter_page: - "Class for showing filters / filter settings" - @api.deco.deluge_page - def GET(self, args): - new_filter = new_filter_form() - filters = sclient.feeder_get_filters() - - # List filters - txt = "" - for filter in filters: - txt = """%(old)s -
  • - %(new)s -
  • """ % {'old':txt, 'new':filter} - - return api.render.feeder.filters(txt, new_filter) - - def POST(self): - "Saves the new filter" - name = api.utils.get_newforms_data(new_filter_form)['name'] - sclient.feeder_add_filter(name) - return self.GET(name) - -class new_filter_form(forms.Form): - "basic form for a new label" - name = forms.CharField(label="") - -class filter_settings_page: - "Class for showing filter settings" - @api.deco.deluge_page - def GET(self, filter): - form = filter_settings_form(filter) - return api.render.feeder.filter_settings(form, filter) - - def POST(self, filter): - opts = api.utils.get_newforms_data(filter_settings_form) - - # apparently the "Unlimited" options still have to be changed - # to -1 (wtf?) - # FIXME there is probably a very much better way to ensure that - # all values have the right types... not to mention to convert "Unlimited" - # to -1... - try: - opts['max_upload_speed'] = int(opts['max_upload_speed']) - except: - opts['max_upload_speed'] = int(-1) - try: - opts['max_download_speed'] = int(opts['max_download_speed']) - except: - opts['max_download_speed'] = int(-1) - try: - opts['max_connections'] = int(opts['max_connections']) - except: - opts['max_connections'] = int(-1) - try: - opts['max_upload_slots'] = int(opts['max_upload_slots']) - except: - opts['max_upload_slots'] = int(-1) - """opts['max_upload_slots'] = long(opts['max_upload_slots']) - opts['max_connections'] = long(opts['max_connections'])""" - - # TODO filter settings per feed not implemented. - opts['feeds'] = [] - - sclient.feeder_set_filter_config(filter, opts) - return self.GET(filter) - -class filter_settings_form(forms.Form): - "form for filter settings" - - def __init__(self, filter, test=False): - self.filtername = filter # We want to save our filtername - forms.Form.__init__(self) - - def initial_data(self): - self.conf = sclient.feeder_get_filter_config(self.filtername) - return self.conf - - def post_html(self): - regex = self.conf["regex"] - hits = sclient.feeder_test_filter(regex) - if not hits: - return "No hits" - list = "" - for hit in hits: - list = """%(old)s -
  • %(name)s
  • - """ % { "old":list, "link":hits[hit], "name":hit } - return """ -
      - %s -
    - """ % list - - regex = forms.CharField(_("regular_expression")) - all_feeds = forms.CheckBox(_("all_feeds")) - active = forms.CheckBox(_("active")) - - #maximum: - max_download_speed = forms.DelugeFloat(_("max_download_speed")) - max_upload_speed = forms.DelugeFloat(_("max_upload_speed")) - max_upload_slots = forms.DelugeInt(_("max_upload_slots")) - max_connections = forms.DelugeInt(_("max_connections")) - - stop_ratio = forms.DelugeFloat(_("stop_ratio")) - stop_at_ratio = forms.CheckBox(_("stop_at_ratio")) - remove_at_ratio = forms.CheckBox(_("remove_at_ratio")) - - #queue: - auto_managed = forms.CheckBox(_("is_auto_managed")) - prioritize_first_last_pieces = forms.CheckBox(_("prioritize_first_last_pieces")) - - download_location = forms.ServerFolder(_("download_location")) - -class remove_feed_page: - "Class for deleting feeds, redirects to setting page" - @api.deco.deluge_page - def GET(self, feedname): - sclient.feeder_remove_feed(feedname) - return """ - - - Redirecting back to settings - - - - - - - """ - -class remove_filter_page: - "Class for deleting filters, redirects to setting page" - @api.deco.deluge_page - def GET(self, name): - sclient.feeder_remove_filter(name) - return """ - - - Redirecting back to settings - - - - - - - """ - - -class WebUI(WebUIPluginBase): - #map url's to classes: [(url,class), ..] - urls = [('/feeder/filters', filter_page), - ('/feeder/filter_settings/(.*)', filter_settings_page), - ('/feeder/feed_remove/(.*)', remove_feed_page), - ('/feeder/filter_remove/(.*)', remove_filter_page), - ('/feeder/feed/(.*)', feed_page)] - - def enable(self): - api.config_page_manager.register('plugins', 'feeder' ,ConfigForm) - - def disable(self): - api.config_page_manager.deregister('feeder') - -class ConfigForm(forms.Form): - #meta: - title = _("feeder") - - #load/save: - def initial_data(self): - return sclient.feeder_get_config() - - def save(self, data): - cfg = dict(data) - sclient.feeder_add_feed(cfg) - - def pre_html(self): - feeds = sclient.feeder_get_feeds() - filters = sclient.feeder_get_filters() - filterlist = "" - for filter in filters: - filterlist = """ %(old)s
  • %(new)s - - Remove -
  • """ % {'old':filterlist, 'new':filter} - feedlist = "" - for feed in feeds: - feedlist = """%(old)s -
  • %(new)s (%(entrys)s torrents) - - Remove -
  • """ % {'old':feedlist, 'new':feed, 'entrys':len(sclient.feeder_get_items(feed))} - - return """ - - - -
    -

    Feeds

    -
    -

    Filters

    -
    -
    -
      - %(feeds)s -
    -
    -
    -
      - %(filters)s -
    - Add/modify filters -
    -

    Add/change feed settings

    """ % {'feeds':feedlist, 'filters':filterlist} - - name = forms.CharField(label=_("Name of feed")) - url = forms.URLField(label=_("URL of feed")) - updatetime = forms.IntegerField(label=_("Defualt refresh time")) - diff --git a/deluge/plugins/feeder/setup.py b/deluge/plugins/feeder/setup.py deleted file mode 100644 index 4c4a09f8e..000000000 --- a/deluge/plugins/feeder/setup.py +++ /dev/null @@ -1,70 +0,0 @@ -# -# setup.py -# -# Copyright (C) 2008 Fredrik Eriksson -# -# Basic plugin template created by: -# Copyright (C) 2008 Martijn Voncken -# 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. -# -# 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 - -from setuptools import setup - -__plugin_name__ = "feeder" -__author__ = "Fredrik Eriksson" -__author_email__ = "feeder@winterbird.org" -__version__ = "0.4" -__url__ = "" -__license__ = "GPLv3" -__description__ = "A plugin for automatically downloadning torrents from a RSS-feed" -__long_description__ = """""" -__pkg_data__ = {__plugin_name__.lower(): ["template/*", "data/*"]} - -setup( - name=__plugin_name__, - version=__version__, - description=__description__, - author=__author__, - author_email=__author_email__, - url=__url__, - license=__license__, - long_description=__long_description__, - - packages=[__plugin_name__.lower()], - package_data = __pkg_data__, - - entry_points=""" - [deluge.plugin.core] - %s = %s:CorePlugin - [deluge.plugin.gtkui] - %s = %s:GtkUIPlugin - [deluge.plugin.webui] - %s = %s:WebUIPlugin - """ % ((__plugin_name__, __plugin_name__.lower())*3) -) diff --git a/deluge/plugins/stats/create_dev_link.sh b/deluge/plugins/stats/create_dev_link.sh deleted file mode 100755 index 35e5c2a5c..000000000 --- a/deluge/plugins/stats/create_dev_link.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -mkdir temp -export PYTHONPATH=./temp -python setup.py develop --install-dir ./temp -cp ./temp/Stats.egg-link ~/.config/deluge/plugins -rm -fr ./temp diff --git a/deluge/plugins/stats/setup.py b/deluge/plugins/stats/setup.py deleted file mode 100644 index e5ff10494..000000000 --- a/deluge/plugins/stats/setup.py +++ /dev/null @@ -1,81 +0,0 @@ -# -# setup.py -# -# Copyright (C) 2008 Martijn Voncken -# -# Basic plugin template created by: -# Copyright (C) 2008 Martijn Voncken -# 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. -# -# 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. -# -# -# 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 - -from setuptools import setup - -__plugin_name__ = "Stats" -__author__ = "Martijn Voncken" -__author_email__ = "mvoncken@gmail.com" -__version__ = "0.1" -__url__ = "http://deluge-torrent.org" -__license__ = "GPLv3" -__description__ = "" -__long_description__ = """""" -__pkg_data__ = {__plugin_name__.lower(): ["template/*", "data/*"]} - -setup( - name=__plugin_name__, - version=__version__, - description=__description__, - author=__author__, - author_email=__author_email__, - url=__url__, - license=__license__, - long_description=__long_description__, - - packages=[__plugin_name__.lower()], - package_data = __pkg_data__, - - entry_points=""" - [deluge.plugin.core] - %s = %s:CorePlugin - [deluge.plugin.gtkui] - %s = %s:GtkUIPlugin - [deluge.plugin.web] - %s = %s:WebUIPlugin - """ % ((__plugin_name__, __plugin_name__.lower())*3) -) diff --git a/deluge/plugins/stats/stats/__init__.py b/deluge/plugins/stats/stats/__init__.py deleted file mode 100644 index 09d38103c..000000000 --- a/deluge/plugins/stats/stats/__init__.py +++ /dev/null @@ -1,57 +0,0 @@ -# -# __init__.py -# -# Copyright (C) 2008 Martijn Voncken -# -# Basic plugin template created by: -# Copyright (C) 2008 Martijn Voncken -# 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. -# -# 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. -# - -from deluge.plugins.init import PluginInitBase - -class CorePlugin(PluginInitBase): - def __init__(self, plugin_name): - from core import Core as _plugin_cls - self._plugin_cls = _plugin_cls - super(CorePlugin, self).__init__(plugin_name) - -class GtkUIPlugin(PluginInitBase): - def __init__(self, plugin_name): - from gtkui import GtkUI as _plugin_cls - self._plugin_cls = _plugin_cls - super(GtkUIPlugin, self).__init__(plugin_name) - -class WebUIPlugin(PluginInitBase): - def __init__(self, plugin_name): - from webui import WebUI as _plugin_cls - self._plugin_cls = _plugin_cls - super(WebUIPlugin, self).__init__(plugin_name) diff --git a/deluge/plugins/stats/stats/common.py b/deluge/plugins/stats/stats/common.py deleted file mode 100644 index 3a81eaaca..000000000 --- a/deluge/plugins/stats/stats/common.py +++ /dev/null @@ -1,39 +0,0 @@ -# -# common.py -# -# Copyright (C) 2009 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. -# -# 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 pkg_resources -import os.path - -def get_resource(filename): - return pkg_resources.resource_filename("stats", os.path.join("data", filename)) diff --git a/deluge/plugins/stats/stats/core.py b/deluge/plugins/stats/stats/core.py deleted file mode 100644 index e6af5e2d1..000000000 --- a/deluge/plugins/stats/stats/core.py +++ /dev/null @@ -1,169 +0,0 @@ -# -# core.py -# -# Copyright (C) 2009 Ian Martin -# Copyright (C) 2008 Damien Churchill -# Copyright (C) 2008 Martijn Voncken -# Copyright (C) Marcos Pinto 2007 -# -# 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. -# -# 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. -# -# -# 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 - -from twisted.internet.task import LoopingCall -import time - -import deluge -from deluge.log import LOG as log -from deluge.plugins.pluginbase import CorePluginBase -from deluge import component -from deluge import configmanager -from deluge.core.rpcserver import export - -DEFAULT_PREFS = { - "test": "NiNiNi", - "update_interval": 2, #2 seconds. - "length": 150, # 2 seconds * 150 --> 5 minutes. -} - -DEFAULT_TOTALS = { - "total_upload": 0, - "total_download": 0, - "total_payload_upload": 0, - "total_payload_download": 0, - "stats": {} -} - -class Core(CorePluginBase): - totals = {} #class var to catch only updating this once per session in enable. - - def enable(self): - self.core = component.get("Core") - self.stats ={} - - self.config = configmanager.ConfigManager("stats.conf", DEFAULT_PREFS) - self.saved_stats = configmanager.ConfigManager("stats.totals", DEFAULT_TOTALS) - if self.totals == {}: - self.totals.update(self.saved_stats.config) - - self.stats = self.saved_stats["stats"] or {} - - self.stats_keys = [ - "payload_download_rate", - "payload_upload_rate" - ] - self.update_stats() - - self.update_timer = LoopingCall(self.update_stats) - self.update_timer.start(self.config["update_interval"]) - - self.save_timer = LoopingCall(self.save_stats) - self.save_timer.start(60) - - def disable(self): - self.save_stats() - try: - self.update_timer.stop() - self.save_timer.stop() - except: - pass - - def update_stats(self): - try: - status = self.core.get_session_status(self.stats_keys) - for key, value in status.items(): - if key not in self.stats: - self.stats[key] = [] - self.stats[key].insert(0, value) - - for stat_list in self.stats.values(): - if len(stat_list) > self.config["length"]: - stat_list.pop() - self.last_update = time.time() - - except Exception, e: - log.exception(e) - - def save_stats(self): - try: - self.saved_stats["stats"] = self.stats - self.saved_stats.config.update(self.get_totals()) - self.saved_stats.save() - except Exception,e: - log.exception(e) - return True - - - # export: - @export - def get_stats(self, keys): - stats_dict = {} - for key in keys: - if key in self.stats: - stats_dict[key] = self.stats[key] - stats_dict["_last_update"] = self.last_update - return stats_dict - - @export - def get_totals(self): - result = {} - session_totals = self.get_session_totals() - for key in session_totals: - result[key] = self.totals[key] + session_totals[key] - return result - - @export - def get_session_totals(self): - status = self.core.session.status() - return { - "total_upload": status.total_upload, - "total_download": status.total_download, - "total_payload_upload": status.total_payload_upload, - "total_payload_download": status.total_payload_download - } - - @export - def set_config(self, config): - "sets the config dictionary" - for key in config.keys(): - self.config[key] = config[key] - self.config.save() - - @export - def get_config(self): - "returns the config dictionary" - return self.config.config diff --git a/deluge/plugins/stats/stats/data/config.glade b/deluge/plugins/stats/stats/data/config.glade deleted file mode 100644 index e39b5204b..000000000 --- a/deluge/plugins/stats/stats/data/config.glade +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - True - - - True - Test config value: - - - - - True - True - - - 1 - - - - - - diff --git a/deluge/plugins/stats/stats/data/stats.js b/deluge/plugins/stats/stats/data/stats.js deleted file mode 100644 index 57bde50e3..000000000 --- a/deluge/plugins/stats/stats/data/stats.js +++ /dev/null @@ -1,48 +0,0 @@ -/* -Script: stats.js - The javascript client-side code for the Stats plugin. - -Copyright: - (C) Damien Churchill 2009 - 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 3, 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. -*/ - -StatsPlugin = Ext.extend(Deluge.Plugin, { - constructor: function(config) { - config = Ext.apply({ - name: "Stats" - }, config); - StatsPlugin.superclass.constructor.call(this, config); - }, - - onDisable: function() { - }, - - onEnable: function() { - } -}); -new StatsPlugin(); \ No newline at end of file diff --git a/deluge/plugins/stats/stats/data/tabs.glade b/deluge/plugins/stats/stats/data/tabs.glade deleted file mode 100644 index c3616a6a5..000000000 --- a/deluge/plugins/stats/stats/data/tabs.glade +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - True - - - True - - - True - gtk-page-setup - - - - - True - Graphs - - - 1 - - - - - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - - - True - True - GTK_POS_LEFT - - - True - - - - - True - Bandwidth - - - tab - False - - - - - True - - - 1 - - - - - True - Connections - - - tab - 1 - False - - - - - True - - - 2 - - - - - True - Seeds/Peers - - - tab - 2 - False - - - - - - - 1 - - - - - - diff --git a/deluge/plugins/stats/stats/graph.py b/deluge/plugins/stats/stats/graph.py deleted file mode 100644 index 2fba2d7d2..000000000 --- a/deluge/plugins/stats/stats/graph.py +++ /dev/null @@ -1,262 +0,0 @@ -# -# graph.py -# -# Copyright (C) 2008 Damien Churchill -# Copyright (C) 2008 Martijn Voncken -# Copyright (C) Marcos Pinto 2007 -# -# 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. -# -# 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. -# -# -# 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 - -""" -port of old plugin by markybob. -""" -import time -import cairo -from deluge.log import LOG as log -from deluge.ui.client import client - -black = (0, 0, 0) -gray = (0.75, 0.75, 0.75) -white = (1.0, 1.0, 1.0) -darkred = (0.65, 0, 0) -red = (1.0, 0, 0) -green = (0, 1.0, 0) -blue = (0, 0, 1.0) -orange = (1.0, 0.74, 0) - -def default_formatter(value): - return str(value) - -def change_opacity(color, opactiy): - """A method to assist in changing the opactiy of a color inorder to draw the - fills. - """ - color = list(color) - if len(color) == 4: - color[3] = opactiy - else: - color.append(opactiy) - return tuple(color) - -class Graph: - def __init__(self): - self.width = 100 - self.height = 100 - self.length = 150 - self.stat_info = {} - self.line_size = 2 - self.mean_selected = True - self.legend_selected = True - self.max_selected = True - self.black = (0, 0 , 0,) - self.interval = 2 # 2 secs - self.text_bg = (255, 255 , 255, 128) # prototyping - self.set_left_axis() - - def set_left_axis(self, **kargs): - self.left_axis = kargs - - def add_stat(self, stat, label='', axis='left', line=True, fill=True, color=None): - self.stat_info[stat] = { - 'axis': axis, - 'label': label, - 'line': line, - 'fill': fill, - 'color': color - } - - def set_stats(self, stats): - self.last_update = stats["_last_update"] - log.debug("Last update: %s" % self.last_update) - del stats["_last_update"] - self.stats = stats - - def set_config(self, config): - self.length = config["length"] - self.interval = config["update_interval"] - - def draw_to_context(self, context, width, height): - self.ctx = context - self.width, self.height = width, height - try: - self.draw_rect(white, 0, 0, self.width, self.height) - self.draw_x_axis() - self.draw_left_axis() - - if self.legend_selected: - self.draw_legend() - except cairo.Error, e: - log.exception(e) - return self.ctx - - def draw(self, width, height): - self.width = width - self.height = height - - self.surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, self.width, self.height) - self.ctx = cairo.Context(self.surface) - self.draw_rect(white, 0, 0, self.width, self.height) - self.draw_x_axis() - self.draw_left_axis() - - if self.legend_selected: - self.draw_legend() - return self.surface - - def draw_x_axis(self): - duration = float(self.length * self.interval) - start = self.last_update - duration - ratio = (self.width - 40) / duration - seconds_to_minute = 60 - time.localtime(start)[5] - - for i in xrange(0, 5): - text = time.strftime('%H:%M', time.localtime(start + seconds_to_minute + (60*i))) - x = int(ratio * (seconds_to_minute + (60*i))) - self.draw_text(text, x + 46, self.height - 20) - x = x + 59.5 - self.draw_dotted_line(gray, x, 20, x, self.height - 20) - - y = self.height - 22.5 - self.draw_dotted_line(gray, 60, y, int(self.width), y) - - def draw_left_axis(self): - stats = {} - max_values = [] - for stat in self.stat_info: - if self.stat_info[stat]['axis'] == 'left': - stats[stat] = self.stat_info[stat] - stats[stat]['values'] = self.stats[stat] - stats[stat]['fill_color'] = change_opacity(stats[stat]['color'], 0.5) - stats[stat]['color'] = change_opacity(stats[stat]['color'], 0.8) - stats[stat]['max_value'] = max(self.stats[stat]) - max_values.append(stats[stat]['max_value']) - if len(max_values) > 1: - max_value = max(*max_values) - else: - max_value = max_values[0] - - if max_value < self.left_axis['min']: - max_value = self.left_axis['min'] - - height = self.height - self.line_size - 22 - #max_value = float(round(max_value, len(str(max_value)) * -1)) - max_value = float(max_value) - ratio = height / max_value - - for i in xrange(1, 6): - y = int(ratio * ((max_value / 5) * i)) - 0.5 - if i < 5: - self.draw_dotted_line(gray, 60, y, self.width, y) - text = self.left_axis['formatter']((max_value / 5) * (5 - i)) - self.draw_text(text, 0, y - 6) - self.draw_dotted_line(gray, 60.5, 20, 60.5, self.height - 20) - - for stat, info in stats.iteritems(): - self.draw_value_poly(info['values'], info['color'], max_value) - self.draw_value_poly(info['values'], info['fill_color'], max_value, info['fill']) - - def draw_legend(self): - pass - - def trace_path(self, values, max_value): - height = self.height - 24 - width = self.width - line_width = self.line_size - - self.ctx.set_line_width(line_width) - self.ctx.move_to(width, height) - - self.ctx.line_to(width, - int(height - ((height - 28) * values[0] / max_value))) - - x = width - step = (width - 60) / float(self.length) - for i, value in enumerate(values): - if i == self.length - 1: - x = 62 - self.ctx.line_to(x, - int(height - 1 - ((height - 28) * value / max_value)) - ) - x -= step - - self.ctx.line_to( - int(width + 62 - (((len(values) - 1) * width) / (self.length - 1))), - height) - self.ctx.close_path() - - def draw_value_poly(self, values, color, max_value, fill=False): - self.trace_path(values, max_value) - self.ctx.set_source_rgba(*color) - - if fill: - self.ctx.fill() - else: - self.ctx.stroke() - - def draw_text(self, text, x, y): - self.ctx.set_font_size(9) - self.ctx.move_to(x, y + 9) - self.ctx.set_source_rgba(*self.black) - self.ctx.show_text(text) - - def draw_rect(self, color, x, y, height, width): - self.ctx.set_source_rgba(*color) - self.ctx.rectangle(x, y, height, width) - self.ctx.fill() - - def draw_line(self, color, x1, y1, x2, y2): - self.ctx.set_source_rgba(*color) - self.ctx.set_line_width(1) - self.ctx.move_to(x1, y1) - self.ctx.line_to(x2, y2) - self.ctx.stroke() - - def draw_dotted_line(self, color, x1, y1, x2, y2): - self.ctx.set_source_rgba(*color) - self.ctx.set_line_width(1) - self.ctx.move_to(x1, y1) - self.ctx.line_to(x2, y2) - #self.ctx.stroke_preserve() - #self.ctx.set_source_rgba(*white) - #self.ctx.set_dash((1, 1), 4) - self.ctx.stroke() - #self.ctx.set_dash((1, 1), 0) - -if __name__ == "__main__": - import test diff --git a/deluge/plugins/stats/stats/gtkui.py b/deluge/plugins/stats/stats/gtkui.py deleted file mode 100644 index 30888ed37..000000000 --- a/deluge/plugins/stats/stats/gtkui.py +++ /dev/null @@ -1,151 +0,0 @@ -# -# gtkui.py -# -# Copyright (C) 2008 Martijn Voncken -# -# Basic plugin template created by: -# Copyright (C) 2008 Martijn Voncken -# 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. -# -# 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. -# -# -# 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 - -import gtk -import gobject -from gtk.glade import XML - -from twisted.internet import defer - -import graph -from deluge import component -from deluge.log import LOG as log -from deluge.common import fspeed -from deluge.ui.client import client -from deluge.ui.gtkui.torrentdetails import Tab -from deluge.plugins.pluginbase import GtkPluginBase - -class GraphsTab(Tab): - def __init__(self, glade): - Tab.__init__(self) - self._name = 'Graphs' - self.glade = glade - self.window = self.glade.get_widget('graph_tab') - self._child_widget = self.window - self.notebook = self.glade.get_widget('graph_notebook') - self.label = self.glade.get_widget('graph_label') - self._tab_label = self.label - self.bandwidth_graph = self.glade.get_widget('bandwidth_graph') - self.bandwidth_graph.connect('expose_event', self.expose) - self.window.unparent() - self.label.unparent() - - self.graph_widget = self.bandwidth_graph - self.graph = graph.Graph() - self.graph.add_stat('payload_download_rate', label='Download Rate', color=graph.green) - self.graph.add_stat('payload_upload_rate', label='Upload Rate', color=graph.blue) - self.graph.set_left_axis(formatter=fspeed, min=10240) - - def expose(self, widget, event): - """Redraw""" - context = self.graph_widget.window.cairo_create() - # set a clip region - context.rectangle(event.area.x, event.area.y, - event.area.width, event.area.height) - context.clip() - - width, height = self.graph_widget.allocation.width, self.graph_widget.allocation.height - self.graph.draw_to_context(context, width, height) - #Do not propagate the event - return False - - def update(self): - log.debug("getstat keys: %s", self.graph.stat_info.keys()) - d1 = client.stats.get_stats(self.graph.stat_info.keys()) - d1.addCallback(self.graph.set_stats) - d2 = client.stats.get_config() - d2.addCallback(self.graph.set_config) - dl = defer.DeferredList([d1, d2]) - - def _on_update(result): - width, height = self.graph_widget.allocation.width, self.graph_widget.allocation.height - rect = gtk.gdk.Rectangle(0, 0, width, height) - self.graph_widget.window.invalidate_rect(rect, True) - - dl.addCallback(_on_update) - - def clear(self): - pass - - - -class GtkUI(GtkPluginBase): - def enable(self): - log.debug("Stats plugin enable called") - self.glade = XML(self.get_resource("config.glade")) - component.get("Preferences").add_page("Stats", self.glade.get_widget("prefs_box")) - component.get("PluginManager").register_hook("on_apply_prefs", self.on_apply_prefs) - component.get("PluginManager").register_hook("on_show_prefs", self.on_show_prefs) - self.on_show_prefs() - - self.graphs_tab = GraphsTab(XML(self.get_resource("tabs.glade"))) - self.torrent_details = component.get('TorrentDetails') - self.torrent_details.add_tab(self.graphs_tab) - - def disable(self): - component.get("Preferences").remove_page("Stats") - component.get("PluginManager").deregister_hook("on_apply_prefs", self.on_apply_prefs) - component.get("PluginManager").deregister_hook("on_show_prefs", self.on_show_prefs) - self.torrent_details.remove_tab(self.graphs_tab.get_name()) - - def on_apply_prefs(self): - log.debug("applying prefs for Stats") - config = { - "test":self.glade.get_widget("txt_test").get_text() - } - client.stats.set_config(config) - - def on_show_prefs(self): - client.stats.get_config().addCallback(self.cb_get_config) - - def cb_get_config(self, config): - "callback for on show_prefs" - self.glade.get_widget("txt_test").set_text(config["test"]) - - def get_resource(self, filename): - import pkg_resources, os - return pkg_resources.resource_filename("stats", os.path.join("data", filename)) diff --git a/deluge/plugins/stats/stats/test.html b/deluge/plugins/stats/stats/test.html deleted file mode 100644 index 7af5f1502..000000000 --- a/deluge/plugins/stats/stats/test.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - - -
    - - - diff --git a/deluge/plugins/stats/stats/test.py b/deluge/plugins/stats/stats/test.py deleted file mode 100644 index 373e97032..000000000 --- a/deluge/plugins/stats/stats/test.py +++ /dev/null @@ -1,78 +0,0 @@ -from deluge.ui.client import sclient, aclient -sclient.set_core_uri() -import graph -import deluge - -def test_sync(): - if 1: - upload = sclient.graph_get_upload() - download = sclient.graph_get_download() - print upload - print download - else: - upload = [66804, 66915, 66974, 67447, 67540, 67318, 67320, 67249, 66659, 66489, 67027, 66914, 66802, 67303, 67654, 67643, 67763, 67528, 67523, 67431, 67214, 66939, 67316, 67020, 66881, 67103, 67377, 67141, 67366, 67492, 67375, 67203, 67056, 67010, 67029, 66741, 66695, 66868, 66805, 66264, 66249, 66317, 66459, 66306, 66681, 66954, 66662, 66278, 65921, 65695, 65681, 65942, 66000, 66140, 66424, 66480, 66257, 66271, 66145, 65854, 65568, 65268, 65112, 65050, 65027, 64676, 64655, 64178, 64386, 63979, 63271, 62746, 62337, 62297, 62496, 62902, 63801, 64121, 62957, 62921, 63051, 62644, 63240, 64107, 63968, 63987, 63644, 63263, 63153, 62999, 62843, 62777, 63101, 63078, 63178, 63126, 63401, 62630, 62451, 62505, 62254, 61485, 61264, 60937, 60568, 61011, 61109, 60325, 60196, 59640, 59619, 59514, 60813, 60572, 61632, 61689, 63365, 64583, 66396, 67179, 68209, 68295, 67674, 67559, 67195, 66178, 65632, 66124, 66456, 66676, 67183, 67620, 66960, 66347, 65925, 65907, 65896, 66738, 66703, 67060, 67004, 67007, 66329, 65304, 52002, 38969, 25433, 12426, 0, 0] - download = [42926, 43853, 43157, 45470, 44254, 46272, 45083, 47344, 46716, 51963, 50112, 52334, 55525, 57545, 53691, 51637, 49574, 49836, 48295, 49843, 52878, 56014, 56966, 56938, 60065, 60461, 56542, 59526, 58678, 54424, 51862, 55109, 52132, 53783, 51687, 56567, 52182, 50758, 46714, 50511, 48161, 50920, 48694, 50528, 55074, 55420, 55882, 59268, 59958, 57938, 57115, 51424, 51180, 53184, 52879, 51177, 54417, 51097, 47901, 49870, 55865, 61118, 61476, 63498, 58878, 49630, 45975, 45632, 45892, 44855, 49495, 48304, 45829, 42152, 39403, 37574, 32384, 34933, 34901, 33492, 31953, 36271, 33826, 34515, 36408, 41106, 43054, 44110, 40810, 41383, 37267, 35881, 38660, 37525, 34857, 36718, 36842, 34281, 39528, 41854, 42952, 40021, 41722, 41045, 42917, 39287, 38672, 32824, 28765, 22686, 18490, 15714, 15268, 14793, 15305, 16354, 16720, 17502, 17857, 16622, 18447, 19929, 31138, 36965, 36158, 32795, 30445, 21997, 18100, 22491, 27227, 29317, 32436, 35700, 39140, 36258, 33697, 24751, 20354, 8211, 3836, 1560, 834, 2034, 1744, 1637, 1637, 1637, 0, 0] - - from graph import NetworkGraph - n = NetworkGraph() - n.savedUpSpeeds = upload - n.savedDownSpeeds = download - - n.draw(800,200) - n.surface.write_to_png('output_sync.png') - -def test_async(): - g = graph.Graph() - g.add_stat('download_rate', color=graph.green) - g.add_stat('upload_rate', color=graph.blue) - g.set_left_axis(formatter=deluge.common.fspeed, min=10240) - g.async_request() - aclient.force_call(True) - surface = g.draw(600, 300) - surface.write_to_png('output_async.png') - -def test_dht(): - """'boring graph, but testing if it works'""" - - g = graph.Graph() - g.add_stat('dht_nodes', color=graph.orange) - g.add_stat('dht_cache_nodes', color=graph.blue) - g.add_stat('dht_torrents', color=graph.green) - g.add_stat('num_connections', color=graph.darkred) #testing : non dht - g.set_left_axis(formatter=str, min=10) - g.async_request() - aclient.force_call(True) - surface = g.draw(600, 300) - surface.write_to_png('output_dht.png') - - -def test_write(): - """ - writing to a file-like object; need this for webui. - """ - class fake_file: - def __init__(self): - self.data = [] - def write(self, str): - self.data.append(str) - - g = graph.Graph() - g.add_stat('download_rate', color=graph.green) - g.add_stat('upload_rate', color=graph.blue) - g.set_left_axis(formatter=deluge.common.fspeed, min=10240) - g.async_request() - aclient.force_call(True) - surface = g.draw(900, 150) - - file_like = fake_file() - surface.write_to_png(file_like) - data = "".join(file_like.data) - - f = open("file_like.png","wb") - f.write(data) - f.close() - -#test_sync() -test_async() -test_dht() -#test_write() \ No newline at end of file diff --git a/deluge/plugins/stats/stats/test.sh b/deluge/plugins/stats/stats/test.sh deleted file mode 100644 index 937c39b5e..000000000 --- a/deluge/plugins/stats/stats/test.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -while true; do - python test.py - sleep 2 -done; diff --git a/deluge/plugins/stats/stats/test_total.py b/deluge/plugins/stats/stats/test_total.py deleted file mode 100644 index ff64877ca..000000000 --- a/deluge/plugins/stats/stats/test_total.py +++ /dev/null @@ -1,23 +0,0 @@ -from deluge.ui.client import sclient, aclient -from deluge.common import fsize -sclient.set_core_uri() - -def print_totals(totals): - for name, value in totals.iteritems(): - print name , fsize(value) - - print "overhead:" - print "up:", fsize(totals["total_upload"] - totals["total_payload_upload"] ) - print "down:", fsize(totals["total_download"] - totals["total_payload_download"] ) - - -print "==totals==" -print_totals(sclient.stats_get_totals()) - -print "==session totals==" -print_totals(sclient.stats_get_session_totals()) - - - - - diff --git a/deluge/plugins/stats/stats/webui.py b/deluge/plugins/stats/stats/webui.py deleted file mode 100644 index b1a235297..000000000 --- a/deluge/plugins/stats/stats/webui.py +++ /dev/null @@ -1,54 +0,0 @@ -# -# webui.py -# -# Copyright (C) 2009 Damien Churchill -# -# 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. -# -# 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. -# -# - -from deluge.log import LOG as log -from deluge.ui.client import client -from deluge import component -from deluge.plugins.pluginbase import WebPluginBase - -from common import get_resource - -class WebUI(WebPluginBase): - - scripts = [get_resource("stats.js")] - - # The enable and disable methods are not scrictly required on the WebUI - # plugins. They are only here if you need to register images/stylesheets - # with the webserver. - def enable(self): - log.debug("Stats Web plugin enabled!") - - def disable(self): - log.debug("Stats Web plugin disabled!")