Change core methods to use a list of torrent_ids.

This commit is contained in:
Andrew Resch 2008-02-21 20:23:02 +00:00
parent 6d63307623
commit 27ffaab15b
2 changed files with 47 additions and 45 deletions

View File

@ -330,27 +330,31 @@ class Core(
return self.export_add_torrent_file(
filename, filedump, options)
def export_remove_torrent(self, torrent_id, remove_torrent, remove_data):
log.debug("Removing torrent %s from the core.", torrent_id)
if self.torrents.remove(torrent_id, remove_torrent, remove_data):
# Run the plugin hooks for 'post_torrent_remove'
self.plugins.run_post_torrent_remove(torrent_id)
# Emit the torrent_removed signal
self.torrent_removed(torrent_id)
def export_remove_torrent(self, torrent_ids, remove_torrent, remove_data):
log.debug("Removing torrent %s from the core.", torrent_ids)
for torrent_id in torrent_ids:
if self.torrents.remove(torrent_id, remove_torrent, remove_data):
# Run the plugin hooks for 'post_torrent_remove'
self.plugins.run_post_torrent_remove(torrent_id)
# Emit the torrent_removed signal
self.torrent_removed(torrent_id)
def export_force_reannounce(self, torrent_id):
log.debug("Forcing reannouncment to trackers of torrent %s", torrent_id)
self.torrents[torrent_id].force_reannounce()
def export_force_reannounce(self, torrent_ids):
log.debug("Forcing reannouncment to: %s", torrent_ids)
for torrent_id in torrent_ids:
self.torrents[torrent_id].force_reannounce()
def export_pause_torrent(self, torrent_id):
log.debug("Pausing torrent %s", torrent_id)
if not self.torrents[torrent_id].pause():
log.warning("Error pausing torrent %s", torrent_id)
def export_pause_torrent(self, torrent_ids):
log.debug("Pausing: %s", torrent_ids)
for torrent_id in torrent_ids:
if not self.torrents[torrent_id].pause():
log.warning("Error pausing torrent %s", torrent_id)
def export_move_torrent(self, torrent_id, dest):
log.debug("Moving torrent %s to %s", torrent_id, dest)
if not self.torrents[torrent_id].move_storage(dest):
log.warning("Error moving torrent %s to %s", torrent_id, dest)
def export_move_torrent(self, torrent_ids, dest):
log.debug("Moving torrents %s to %s", torrent_id, dest)
for torrent_id in torrent_ids:
if not self.torrents[torrent_id].move_storage(dest):
log.warning("Error moving torrent %s to %s", torrent_id, dest)
def export_pause_all_torrents(self):
"""Pause all torrents in the session"""
@ -363,10 +367,11 @@ class Core(
# Emit the 'torrent_all_resumed' signal
self.torrent_all_resumed()
def export_resume_torrent(self, torrent_id):
log.debug("Resuming torrent %s", torrent_id)
if self.torrents[torrent_id].resume():
self.torrent_resumed(torrent_id)
def export_resume_torrent(self, torrent_ids):
log.debug("Resuming: %s", torrent_ids)
for torrent_id in torrent_ids:
if self.torrents[torrent_id].resume():
self.torrent_resumed(torrent_id)
def export_get_torrent_status(self, torrent_id, keys):
# Build the status dictionary
@ -467,9 +472,10 @@ class Core(
self.plugins.disable_plugin(plugin)
return None
def export_force_recheck(self, torrent_id):
"""Forces a data recheck on torrent_id"""
return self.torrents.force_recheck(torrent_id)
def export_force_recheck(self, torrent_ids):
"""Forces a data recheck on torrent_ids"""
for torrent_id in torrent_ids:
gobject.idle_add(self.torrents.force_recheck, torrent_id)
def export_set_torrent_trackers(self, torrent_id, trackers):
"""Sets a torrents tracker list. trackers will be [{"url", "tier"}]"""

View File

@ -187,12 +187,6 @@ def connected():
return True
return False
def register_client(port):
get_core().call("register_client", None, port)
def deregister_client():
get_core().call("deregister_client", None)
def shutdown():
"""Shutdown the core daemon"""
try:
@ -205,7 +199,15 @@ def force_call(block=True):
"""Forces the multicall batch to go now and not wait for the timer. This
call also blocks until all callbacks have been dealt with."""
get_core().do_multicall(block=block)
## Core methods ##
def register_client(port):
get_core().call("register_client", None, port)
def deregister_client():
get_core().call("deregister_client", None)
def add_torrent_file(torrent_files, torrent_options=None):
"""Adds torrent files to the core
Expects a list of torrent files
@ -252,19 +254,16 @@ def add_torrent_url(torrent_url, options=None):
def remove_torrent(torrent_ids, remove_torrent=False, remove_data=False):
"""Removes torrent_ids from the core.. Expects a list of torrent_ids"""
log.debug("Attempting to removing torrents: %s", torrent_ids)
for torrent_id in torrent_ids:
get_core().call("remove_torrent", None, torrent_id, remove_torrent, remove_data)
log.debug("Attempting to remove torrents: %s", torrent_ids)
get_core().call("remove_torrent", None, torrent_ids, remove_torrent, remove_data)
def pause_torrent(torrent_ids):
"""Pauses torrent_ids"""
for torrent_id in torrent_ids:
get_core().call("pause_torrent", None, torrent_id)
get_core().call("pause_torrent", None, torrent_ids)
def move_torrent(torrent_ids, folder):
"""Pauses torrent_ids"""
for torrent_id in torrent_ids:
get_core().call("move_torrent", None, torrent_id, folder)
get_core().call("move_torrent", None, torrent_ids, folder)
def pause_all_torrents():
"""Pauses all torrents"""
@ -276,13 +275,11 @@ def resume_all_torrents():
def resume_torrent(torrent_ids):
"""Resume torrent_ids"""
for torrent_id in torrent_ids:
get_core().call("resume_torrent", None, torrent_id)
get_core().call("resume_torrent", None, torrent_ids)
def force_reannounce(torrent_ids):
"""Reannounce to trackers"""
for torrent_id in torrent_ids:
get_core().call("force_reannounce", None, torrent_id)
get_core().call("force_reannounce", None, torrent_ids)
def get_torrent_status(callback, torrent_id, keys):
"""Builds the status dictionary and returns it"""
@ -337,8 +334,7 @@ def disable_plugin(plugin):
def force_recheck(torrent_ids):
"""Forces a data recheck on torrent_ids"""
for torrent_id in torrent_ids:
get_core().call("force_recheck", None, torrent_id)
get_core().call("force_recheck", None, torrent_ids)
def set_torrent_trackers(torrent_id, trackers):
"""Sets the torrents trackers"""