diff --git a/deluge/core/autoadd.py b/deluge/core/autoadd.py deleted file mode 100644 index acab22097..000000000 --- a/deluge/core/autoadd.py +++ /dev/null @@ -1,137 +0,0 @@ -# -# autoadd.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 os -import logging - -from deluge._libtorrent import lt - -import deluge.component as component -from deluge.configmanager import ConfigManager - -MAX_NUM_ATTEMPTS = 10 - -log = logging.getLogger(__name__) - -class AutoAdd(component.Component): - def __init__(self): - component.Component.__init__(self, "AutoAdd", depend=["TorrentManager"], interval=5) - # Get the core config - self.config = ConfigManager("core.conf") - - # A list of filenames - self.invalid_torrents = [] - # Filename:Attempts - self.attempts = {} - - # Register set functions - self.config.register_set_function("autoadd_enable", - self._on_autoadd_enable, apply_now=True) - self.config.register_set_function("autoadd_location", - self._on_autoadd_location) - - def update(self): - if not self.config["autoadd_enable"]: - # We shouldn't be updating because autoadd is not enabled - component.pause("AutoAdd") - return - - # Check the auto add folder for new torrents to add - if not os.path.isdir(self.config["autoadd_location"]): - log.warning("Invalid AutoAdd folder: %s", self.config["autoadd_location"]) - component.pause("AutoAdd") - return - - for filename in os.listdir(self.config["autoadd_location"]): - try: - filepath = os.path.join(self.config["autoadd_location"], filename) - except UnicodeDecodeError, e: - log.error("Unable to auto add torrent due to improper filename encoding: %s", e) - continue - if os.path.isfile(filepath) and filename.endswith(".torrent"): - try: - filedump = self.load_torrent(filepath) - except (RuntimeError, Exception), e: - # If the torrent is invalid, we keep track of it so that we - # can try again on the next pass. This is because some - # torrents may not be fully saved during the pass. - log.debug("Torrent is invalid: %s", e) - if filename in self.invalid_torrents: - self.attempts[filename] += 1 - if self.attempts[filename] >= MAX_NUM_ATTEMPTS: - os.rename(filepath, filepath + ".invalid") - del self.attempts[filename] - self.invalid_torrents.remove(filename) - else: - self.invalid_torrents.append(filename) - self.attempts[filename] = 1 - continue - - # The torrent looks good, so lets add it to the session - component.get("TorrentManager").add(filedump=filedump, filename=filename) - - os.remove(filepath) - - def load_torrent(self, filename): - try: - log.debug("Attempting to open %s for add.", filename) - _file = open(filename, "rb") - filedump = _file.read() - if not filedump: - raise RuntimeError, "Torrent is 0 bytes!" - _file.close() - except IOError, e: - log.warning("Unable to open %s: %s", filename, e) - raise e - - # Get the info to see if any exceptions are raised - info = lt.torrent_info(lt.bdecode(filedump)) - - return filedump - - def _on_autoadd_enable(self, key, value): - log.debug("_on_autoadd_enable") - if value: - component.resume("AutoAdd") - else: - component.pause("AutoAdd") - - def _on_autoadd_location(self, key, value): - log.debug("_on_autoadd_location") - # We need to resume the component just incase it was paused due to - # an invalid autoadd location. - if self.config["autoadd_enable"]: - component.resume("AutoAdd") diff --git a/deluge/core/preferencesmanager.py b/deluge/core/preferencesmanager.py index e22e9cfe5..ba1d2294b 100644 --- a/deluge/core/preferencesmanager.py +++ b/deluge/core/preferencesmanager.py @@ -86,8 +86,6 @@ DEFAULT_PREFS = { "max_upload_speed_per_torrent": -1, "max_download_speed_per_torrent": -1, "enabled_plugins": [], - "autoadd_location": deluge.common.get_default_download_dir(), - "autoadd_enable": False, "add_paused": False, "max_active_seeding": 5, "max_active_downloading": 3, diff --git a/deluge/ui/gtkui/glade/preferences_dialog.glade b/deluge/ui/gtkui/glade/preferences_dialog.glade index 9383846a0..05ea703ff 100644 --- a/deluge/ui/gtkui/glade/preferences_dialog.glade +++ b/deluge/ui/gtkui/glade/preferences_dialog.glade @@ -115,23 +115,10 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 5 - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - select-folder - - - 0 - + - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - 1 - + @@ -179,22 +166,6 @@ 2 - - - Auto add .torrents from: - True - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - True - - - - 2 - 3 - GTK_FILL - - Move completed to: @@ -323,6 +294,9 @@ 15 + + + diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index 6ba21e1ae..e3c744d33 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -135,9 +135,6 @@ DEFAULT_PREFS = { "autoconnect": False, "autoconnect_host_id": None, "autostart_localhost": False, - "autoadd_queued": False, - "autoadd_enable": False, - "autoadd_location": "", "choose_directory_dialog_path": deluge.common.get_default_download_dir(), "show_new_releases": True, "signal_port": 40000, diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index 508effa4a..83f681f76 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -275,10 +275,6 @@ class Preferences(component.Component): ("active", self.core_config["del_copy_torrent_file"]), "torrent_files_button": \ ("filename", self.core_config["torrentfiles_location"]), - "chk_autoadd": \ - ("active", self.core_config["autoadd_enable"]), - "folder_autoadd": \ - ("filename", self.core_config["autoadd_location"]), "radio_compact_allocation": \ ("active", self.core_config["compact_allocation"]), "radio_full_allocation": \ @@ -375,11 +371,6 @@ class Preferences(component.Component): self.glade.get_widget("torrent_files_button").hide() core_widgets.pop("torrent_files_button") core_widgets["entry_torrents_path"] = ("text", self.core_config["torrentfiles_location"]) - - self.glade.get_widget("entry_autoadd").show() - self.glade.get_widget("folder_autoadd").hide() - core_widgets.pop("folder_autoadd") - core_widgets["entry_autoadd"] = ("text", self.core_config["autoadd_location"]) else: self.glade.get_widget("entry_download_path").hide() self.glade.get_widget("download_path_button").show() @@ -387,8 +378,6 @@ class Preferences(component.Component): self.glade.get_widget("move_completed_path_button").show() self.glade.get_widget("entry_torrents_path").hide() self.glade.get_widget("torrent_files_button").show() - self.glade.get_widget("entry_autoadd").hide() - self.glade.get_widget("folder_autoadd").show() # Update the widgets accordingly for key in core_widgets.keys(): @@ -427,8 +416,6 @@ class Preferences(component.Component): "chk_copy_torrent_file", "chk_del_copy_torrent_file", "torrent_files_button", - "chk_autoadd", - "folder_autoadd", "radio_compact_allocation", "radio_full_allocation", "chk_prioritize_first_last_pieces", @@ -589,15 +576,6 @@ class Preferences(component.Component): new_core_config["torrentfiles_location"] = \ self.glade.get_widget("entry_torrents_path").get_text() - new_core_config["autoadd_enable"] = \ - self.glade.get_widget("chk_autoadd").get_active() - if client.is_localhost(): - new_core_config["autoadd_location"] = \ - self.glade.get_widget("folder_autoadd").get_filename() - else: - new_core_config["autoadd_location"] = \ - self.glade.get_widget("entry_autoadd").get_text() - new_core_config["compact_allocation"] = \ self.glade.get_widget("radio_compact_allocation").get_active() new_core_config["prioritize_first_last_pieces"] = \ @@ -836,7 +814,6 @@ class Preferences(component.Component): "chk_move_completed" : {"move_completed_path_button" : True}, "chk_copy_torrent_file" : {"torrent_files_button" : True, "chk_del_copy_torrent_file" : True}, - "chk_autoadd" : {"folder_autoadd" : True}, "chk_seed_ratio" : {"spin_share_ratio": True, "chk_remove_ratio" : True} }