remove the now redundant calls

This commit is contained in:
Damien Churchill 2009-03-17 09:16:35 +00:00
parent fc68ec2929
commit 5512606f8a
1 changed files with 61 additions and 61 deletions

View File

@ -223,7 +223,7 @@ class Core(component.Component):
return False return False
# Exported Methods # Exported Methods
@export() @export
def add_torrent_file(self, filename, filedump, options): def add_torrent_file(self, filename, filedump, options):
""" """
Adds a torrent file to the session. Adds a torrent file to the session.
@ -247,7 +247,7 @@ class Core(component.Component):
log.error("There was an error adding the torrent file %s", filename) log.error("There was an error adding the torrent file %s", filename)
log.exception(e) log.exception(e)
@export() @export
def add_torrent_url(self, url, options): def add_torrent_url(self, url, options):
""" """
Adds a torrent from a url. Deluge will attempt to fetch the torrent Adds a torrent from a url. Deluge will attempt to fetch the torrent
@ -272,7 +272,7 @@ class Core(component.Component):
twisted.web.client.getPage(url).addCallback(on_get_page).addErrback(on_get_page_error) twisted.web.client.getPage(url).addCallback(on_get_page).addErrback(on_get_page_error)
@export() @export
def add_torrent_magnets(self, uris, options): def add_torrent_magnets(self, uris, options):
for uri in uris: for uri in uris:
log.debug("Attempting to add by magnet uri: %s", uri) log.debug("Attempting to add by magnet uri: %s", uri)
@ -283,13 +283,13 @@ class Core(component.Component):
torrent_id = self.torrentmanager.add(magnet=uri, options=option) torrent_id = self.torrentmanager.add(magnet=uri, options=option)
@export() @export
def remove_torrent(self, torrent_ids, remove_data): def remove_torrent(self, torrent_ids, remove_data):
log.debug("Removing torrent %s from the core.", torrent_ids) log.debug("Removing torrent %s from the core.", torrent_ids)
for torrent_id in torrent_ids: for torrent_id in torrent_ids:
self.torrentmanager.remove(torrent_id, remove_data) self.torrentmanager.remove(torrent_id, remove_data)
@export() @export
def get_stats(self): def get_stats(self):
""" """
document me!!! document me!!!
@ -309,7 +309,7 @@ class Core(component.Component):
return stats return stats
@export() @export
def get_session_status(self, keys): def get_session_status(self, keys):
""" """
Gets the session status values for 'keys' Gets the session status values for 'keys'
@ -326,57 +326,57 @@ class Core(component.Component):
return status return status
@export() @export
def force_reannounce(self, torrent_ids): def force_reannounce(self, torrent_ids):
log.debug("Forcing reannouncment to: %s", torrent_ids) log.debug("Forcing reannouncment to: %s", torrent_ids)
for torrent_id in torrent_ids: for torrent_id in torrent_ids:
self.torrentmanager[torrent_id].force_reannounce() self.torrentmanager[torrent_id].force_reannounce()
@export() @export
def pause_torrent(self, torrent_ids): def pause_torrent(self, torrent_ids):
log.debug("Pausing: %s", torrent_ids) log.debug("Pausing: %s", torrent_ids)
for torrent_id in torrent_ids: for torrent_id in torrent_ids:
if not self.torrentmanager[torrent_id].pause(): if not self.torrentmanager[torrent_id].pause():
log.warning("Error pausing torrent %s", torrent_id) log.warning("Error pausing torrent %s", torrent_id)
@export() @export
def connect_peer(self, torrent_id, ip, port): def connect_peer(self, torrent_id, ip, port):
log.debug("adding peer %s to %s", ip, torrent_id) log.debug("adding peer %s to %s", ip, torrent_id)
if not self.torrentmanager[torrent_id].connect_peer(ip, port): if not self.torrentmanager[torrent_id].connect_peer(ip, port):
log.warning("Error adding peer %s:%s to %s", ip, port, torrent_id) log.warning("Error adding peer %s:%s to %s", ip, port, torrent_id)
@export() @export
def move_storage(self, torrent_ids, dest): def move_storage(self, torrent_ids, dest):
log.debug("Moving storage %s to %s", torrent_ids, dest) log.debug("Moving storage %s to %s", torrent_ids, dest)
for torrent_id in torrent_ids: for torrent_id in torrent_ids:
if not self.torrentmanager[torrent_id].move_storage(dest): if not self.torrentmanager[torrent_id].move_storage(dest):
log.warning("Error moving torrent %s to %s", torrent_id, dest) log.warning("Error moving torrent %s to %s", torrent_id, dest)
@export() @export
def pause_all_torrents(self): def pause_all_torrents(self):
"""Pause all torrents in the session""" """Pause all torrents in the session"""
self.session.pause() self.session.pause()
@export() @export
def resume_all_torrents(self): def resume_all_torrents(self):
"""Resume all torrents in the session""" """Resume all torrents in the session"""
self.session.resume() self.session.resume()
component.get("EventManager").emit(SessionResumedEvent()) component.get("EventManager").emit(SessionResumedEvent())
@export() @export
def resume_torrent(self, torrent_ids): def resume_torrent(self, torrent_ids):
log.debug("Resuming: %s", torrent_ids) log.debug("Resuming: %s", torrent_ids)
for torrent_id in torrent_ids: for torrent_id in torrent_ids:
self.torrentmanager[torrent_id].resume() self.torrentmanager[torrent_id].resume()
@export() @export
def get_status_keys(self): def get_status_keys(self):
""" """
returns all possible keys for the keys argument in get_torrent(s)_status. returns all possible keys for the keys argument in get_torrent(s)_status.
""" """
return STATUS_KEYS + self.pluginmanager.status_fields.keys() return STATUS_KEYS + self.pluginmanager.status_fields.keys()
@export() @export
def get_torrent_status(self, torrent_id, keys): def get_torrent_status(self, torrent_id, keys):
# Build the status dictionary # Build the status dictionary
status = self.torrentmanager[torrent_id].get_status(keys) status = self.torrentmanager[torrent_id].get_status(keys)
@ -387,7 +387,7 @@ class Core(component.Component):
status.update(self.pluginmanager.get_status(torrent_id, leftover_fields)) status.update(self.pluginmanager.get_status(torrent_id, leftover_fields))
return status return status
@export() @export
def get_torrents_status(self, filter_dict, keys): def get_torrents_status(self, filter_dict, keys):
""" """
returns all torrents , optionally filtered by filter_dict. returns all torrents , optionally filtered by filter_dict.
@ -401,7 +401,7 @@ class Core(component.Component):
return status_dict return status_dict
@export() @export
def get_filter_tree(self , show_zero_hits=True, hide_cat=None): def get_filter_tree(self , show_zero_hits=True, hide_cat=None):
""" """
returns {field: [(value,count)] } returns {field: [(value,count)] }
@ -409,18 +409,18 @@ class Core(component.Component):
""" """
return self.filtermanager.get_filter_tree(show_zero_hits, hide_cat) return self.filtermanager.get_filter_tree(show_zero_hits, hide_cat)
@export() @export
def get_session_state(self): def get_session_state(self):
"""Returns a list of torrent_ids in the session.""" """Returns a list of torrent_ids in the session."""
# Get the torrent list from the TorrentManager # Get the torrent list from the TorrentManager
return self.torrentmanager.get_torrent_list() return self.torrentmanager.get_torrent_list()
@export() @export
def get_config(self): def get_config(self):
"""Get all the preferences as a dictionary""" """Get all the preferences as a dictionary"""
return self.config.config return self.config.config
@export() @export
def get_config_value(self, key): def get_config_value(self, key):
"""Get the config value for key""" """Get the config value for key"""
try: try:
@ -430,7 +430,7 @@ class Core(component.Component):
return value return value
@export() @export
def get_config_values(self, keys): def get_config_values(self, keys):
"""Get the config values for the entered keys""" """Get the config values for the entered keys"""
config = {} config = {}
@ -441,7 +441,7 @@ class Core(component.Component):
pass pass
return config return config
@export() @export
def set_config(self, config): def set_config(self, config):
"""Set the config with values from dictionary""" """Set the config with values from dictionary"""
# Load all the values into the configuration # Load all the values into the configuration
@ -450,129 +450,129 @@ class Core(component.Component):
config[key] = config[key].encode("utf8") config[key] = config[key].encode("utf8")
self.config[key] = config[key] self.config[key] = config[key]
@export() @export
def get_listen_port(self): def get_listen_port(self):
"""Returns the active listen port""" """Returns the active listen port"""
return self.session.listen_port() return self.session.listen_port()
@export() @export
def get_num_connections(self): def get_num_connections(self):
"""Returns the current number of connections""" """Returns the current number of connections"""
return self.session.num_connections() return self.session.num_connections()
@export() @export
def get_dht_nodes(self): def get_dht_nodes(self):
"""Returns the number of dht nodes""" """Returns the number of dht nodes"""
return self.session.status().dht_nodes return self.session.status().dht_nodes
@export() @export
def get_download_rate(self): def get_download_rate(self):
"""Returns the payload download rate""" """Returns the payload download rate"""
return self.session.status().payload_download_rate return self.session.status().payload_download_rate
@export() @export
def get_upload_rate(self): def get_upload_rate(self):
"""Returns the payload upload rate""" """Returns the payload upload rate"""
return self.session.status().payload_upload_rate return self.session.status().payload_upload_rate
@export() @export
def get_available_plugins(self): def get_available_plugins(self):
"""Returns a list of plugins available in the core""" """Returns a list of plugins available in the core"""
return self.pluginmanager.get_available_plugins() return self.pluginmanager.get_available_plugins()
@export() @export
def get_enabled_plugins(self): def get_enabled_plugins(self):
"""Returns a list of enabled plugins in the core""" """Returns a list of enabled plugins in the core"""
return self.pluginmanager.get_enabled_plugins() return self.pluginmanager.get_enabled_plugins()
@export() @export
def enable_plugin(self, plugin): def enable_plugin(self, plugin):
self.pluginmanager.enable_plugin(plugin) self.pluginmanager.enable_plugin(plugin)
return None return None
@export() @export
def disable_plugin(self, plugin): def disable_plugin(self, plugin):
self.pluginmanager.disable_plugin(plugin) self.pluginmanager.disable_plugin(plugin)
return None return None
@export() @export
def force_recheck(self, torrent_ids): def force_recheck(self, torrent_ids):
"""Forces a data recheck on torrent_ids""" """Forces a data recheck on torrent_ids"""
for torrent_id in torrent_ids: for torrent_id in torrent_ids:
self.torrentmanager[torrent_id].force_recheck() self.torrentmanager[torrent_id].force_recheck()
@export() @export
def set_torrent_options(self, torrent_ids, options): def set_torrent_options(self, torrent_ids, options):
"""Sets the torrent options for torrent_ids""" """Sets the torrent options for torrent_ids"""
for torrent_id in torrent_ids: for torrent_id in torrent_ids:
self.torrentmanager[torrent_id].set_options(options) self.torrentmanager[torrent_id].set_options(options)
@export() @export
def set_torrent_trackers(self, torrent_id, trackers): def set_torrent_trackers(self, torrent_id, trackers):
"""Sets a torrents tracker list. trackers will be [{"url", "tier"}]""" """Sets a torrents tracker list. trackers will be [{"url", "tier"}]"""
return self.torrentmanager[torrent_id].set_trackers(trackers) return self.torrentmanager[torrent_id].set_trackers(trackers)
@export() @export
def set_torrent_max_connections(self, torrent_id, value): def set_torrent_max_connections(self, torrent_id, value):
"""Sets a torrents max number of connections""" """Sets a torrents max number of connections"""
return self.torrentmanager[torrent_id].set_max_connections(value) return self.torrentmanager[torrent_id].set_max_connections(value)
@export() @export
def set_torrent_max_upload_slots(self, torrent_id, value): def set_torrent_max_upload_slots(self, torrent_id, value):
"""Sets a torrents max number of upload slots""" """Sets a torrents max number of upload slots"""
return self.torrentmanager[torrent_id].set_max_upload_slots(value) return self.torrentmanager[torrent_id].set_max_upload_slots(value)
@export() @export
def set_torrent_max_upload_speed(self, torrent_id, value): def set_torrent_max_upload_speed(self, torrent_id, value):
"""Sets a torrents max upload speed""" """Sets a torrents max upload speed"""
return self.torrentmanager[torrent_id].set_max_upload_speed(value) return self.torrentmanager[torrent_id].set_max_upload_speed(value)
@export() @export
def set_torrent_max_download_speed(self, torrent_id, value): def set_torrent_max_download_speed(self, torrent_id, value):
"""Sets a torrents max download speed""" """Sets a torrents max download speed"""
return self.torrentmanager[torrent_id].set_max_download_speed(value) return self.torrentmanager[torrent_id].set_max_download_speed(value)
@export() @export
def set_torrent_file_priorities(self, torrent_id, priorities): def set_torrent_file_priorities(self, torrent_id, priorities):
"""Sets a torrents file priorities""" """Sets a torrents file priorities"""
return self.torrentmanager[torrent_id].set_file_priorities(priorities) return self.torrentmanager[torrent_id].set_file_priorities(priorities)
@export() @export
def set_torrent_prioritize_first_last(self, torrent_id, value): def set_torrent_prioritize_first_last(self, torrent_id, value):
"""Sets a higher priority to the first and last pieces""" """Sets a higher priority to the first and last pieces"""
return self.torrentmanager[torrent_id].set_prioritize_first_last(value) return self.torrentmanager[torrent_id].set_prioritize_first_last(value)
@export() @export
def set_torrent_auto_managed(self, torrent_id, value): def set_torrent_auto_managed(self, torrent_id, value):
"""Sets the auto managed flag for queueing purposes""" """Sets the auto managed flag for queueing purposes"""
return self.torrentmanager[torrent_id].set_auto_managed(value) return self.torrentmanager[torrent_id].set_auto_managed(value)
@export() @export
def set_torrent_stop_at_ratio(self, torrent_id, value): def set_torrent_stop_at_ratio(self, torrent_id, value):
"""Sets the torrent to stop at 'stop_ratio'""" """Sets the torrent to stop at 'stop_ratio'"""
return self.torrentmanager[torrent_id].set_stop_at_ratio(value) return self.torrentmanager[torrent_id].set_stop_at_ratio(value)
@export() @export
def set_torrent_stop_ratio(self, torrent_id, value): def set_torrent_stop_ratio(self, torrent_id, value):
"""Sets the ratio when to stop a torrent if 'stop_at_ratio' is set""" """Sets the ratio when to stop a torrent if 'stop_at_ratio' is set"""
return self.torrentmanager[torrent_id].set_stop_ratio(value) return self.torrentmanager[torrent_id].set_stop_ratio(value)
@export() @export
def set_torrent_remove_at_ratio(self, torrent_id, value): def set_torrent_remove_at_ratio(self, torrent_id, value):
"""Sets the torrent to be removed at 'stop_ratio'""" """Sets the torrent to be removed at 'stop_ratio'"""
return self.torrentmanager[torrent_id].set_remove_at_ratio(value) return self.torrentmanager[torrent_id].set_remove_at_ratio(value)
@export() @export
def set_torrent_move_on_completed(self, torrent_id, value): def set_torrent_move_on_completed(self, torrent_id, value):
"""Sets the torrent to be moved when completed""" """Sets the torrent to be moved when completed"""
return self.torrentmanager[torrent_id].set_move_on_completed(value) return self.torrentmanager[torrent_id].set_move_on_completed(value)
@export() @export
def set_torrent_move_on_completed_path(self, torrent_id, value): def set_torrent_move_on_completed_path(self, torrent_id, value):
"""Sets the path for the torrent to be moved when completed""" """Sets the path for the torrent to be moved when completed"""
return self.torrentmanager[torrent_id].set_move_on_completed_path(value) return self.torrentmanager[torrent_id].set_move_on_completed_path(value)
@export() @export
def block_ip_range(self, range): def block_ip_range(self, range):
"""Block an ip range""" """Block an ip range"""
self.ip_filter.add_rule(range[0], range[1], 1) self.ip_filter.add_rule(range[0], range[1], 1)
@ -584,24 +584,24 @@ class Core(component.Component):
#self.__set_ip_filter_timer = LoopingCall(self.session.set_ip_filter, self.ip_filter) #self.__set_ip_filter_timer = LoopingCall(self.session.set_ip_filter, self.ip_filter)
#self.__set_ip_filter_timer.start(2, False) #self.__set_ip_filter_timer.start(2, False)
@export() @export
def reset_ip_filter(self): def reset_ip_filter(self):
"""Clears the ip filter""" """Clears the ip filter"""
self.ip_filter = lt.ip_filter() self.ip_filter = lt.ip_filter()
self.session.set_ip_filter(self.ip_filter) self.session.set_ip_filter(self.ip_filter)
@export() @export
def get_health(self): def get_health(self):
"""Returns True if we have established incoming connections""" """Returns True if we have established incoming connections"""
return self.session.status().has_incoming_connections return self.session.status().has_incoming_connections
@export() @export
def get_path_size(self, path): def get_path_size(self, path):
"""Returns the size of the file or folder 'path' and -1 if the path is """Returns the size of the file or folder 'path' and -1 if the path is
unaccessible (non-existent or insufficient privs)""" unaccessible (non-existent or insufficient privs)"""
return deluge.common.get_path_size(path) return deluge.common.get_path_size(path)
@export() @export
def create_torrent(self, path, tracker, piece_length, comment, target, def create_torrent(self, path, tracker, piece_length, comment, target,
url_list, private, created_by, httpseeds, add_to_session): url_list, private, created_by, httpseeds, add_to_session):
@ -636,7 +636,7 @@ class Core(component.Component):
if add_to_session: if add_to_session:
self.add_torrent_file(os.path.split(target)[1], open(target, "rb").read(), None) self.add_torrent_file(os.path.split(target)[1], open(target, "rb").read(), None)
@export() @export
def upload_plugin(self, filename, plugin_data): def upload_plugin(self, filename, plugin_data):
"""This method is used to upload new plugins to the daemon. It is used """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 when connecting to the daemon remotely and installing a new plugin on
@ -648,23 +648,23 @@ class Core(component.Component):
f.close() f.close()
component.get("CorePluginManager").scan_for_plugins() component.get("CorePluginManager").scan_for_plugins()
@export() @export
def rescan_plugins(self): def rescan_plugins(self):
"""Rescans the plugin folders for new plugins""" """Rescans the plugin folders for new plugins"""
component.get("CorePluginManager").scan_for_plugins() component.get("CorePluginManager").scan_for_plugins()
@export() @export
def rename_files(self, torrent_id, filenames): def rename_files(self, torrent_id, filenames):
"""Renames files in 'torrent_id'. The 'filenames' parameter should be a """Renames files in 'torrent_id'. The 'filenames' parameter should be a
list of (index, filename) pairs.""" list of (index, filename) pairs."""
self.torrentmanager[torrent_id].rename_files(filenames) self.torrentmanager[torrent_id].rename_files(filenames)
@export() @export
def rename_folder(self, torrent_id, folder, new_folder): def rename_folder(self, torrent_id, folder, new_folder):
"""Renames the 'folder' to 'new_folder' in 'torrent_id'.""" """Renames the 'folder' to 'new_folder' in 'torrent_id'."""
self.torrentmanager[torrent_id].rename_folder(folder, new_folder) self.torrentmanager[torrent_id].rename_folder(folder, new_folder)
@export() @export
def queue_top(self, torrent_ids): def 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)
for torrent_id in torrent_ids: for torrent_id in torrent_ids:
@ -675,7 +675,7 @@ class Core(component.Component):
except KeyError: except KeyError:
log.warning("torrent_id: %s does not exist in the queue", torrent_id) log.warning("torrent_id: %s does not exist in the queue", torrent_id)
@export() @export
def queue_up(self, torrent_ids): def queue_up(self, torrent_ids):
log.debug("Attempting to queue %s to up", torrent_ids) log.debug("Attempting to queue %s to up", torrent_ids)
#torrent_ids must be sorted before moving. #torrent_ids must be sorted before moving.
@ -689,7 +689,7 @@ class Core(component.Component):
except KeyError: except KeyError:
log.warning("torrent_id: %s does not exist in the queue", torrent_id) log.warning("torrent_id: %s does not exist in the queue", torrent_id)
@export() @export
def queue_down(self, torrent_ids): def queue_down(self, torrent_ids):
log.debug("Attempting to queue %s to down", torrent_ids) log.debug("Attempting to queue %s to down", torrent_ids)
#torrent_ids must be sorted before moving. #torrent_ids must be sorted before moving.
@ -703,7 +703,7 @@ class Core(component.Component):
except KeyError: except KeyError:
log.warning("torrent_id: %s does not exist in the queue", torrent_id) log.warning("torrent_id: %s does not exist in the queue", torrent_id)
@export() @export
def queue_bottom(self, torrent_ids): def queue_bottom(self, torrent_ids):
log.debug("Attempting to queue %s to bottom", torrent_ids) log.debug("Attempting to queue %s to bottom", torrent_ids)
for torrent_id in torrent_ids: for torrent_id in torrent_ids:
@ -714,11 +714,11 @@ class Core(component.Component):
except KeyError: except KeyError:
log.warning("torrent_id: %s does not exist in the queue", torrent_id) log.warning("torrent_id: %s does not exist in the queue", torrent_id)
@export() @export
def glob(self, path): def glob(self, path):
return glob.glob(path) return glob.glob(path)
@export() @export
def test_listen_port(self): def test_listen_port(self):
""" Checks if active port is open """ """ Checks if active port is open """
import urllib import urllib