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
commit 27ffaab15b
2 changed files with 47 additions and 45 deletions

View file

@ -330,25 +330,29 @@ class Core(
return self.export_add_torrent_file( return self.export_add_torrent_file(
filename, filedump, options) filename, filedump, options)
def export_remove_torrent(self, torrent_id, remove_torrent, remove_data): def export_remove_torrent(self, torrent_ids, remove_torrent, remove_data):
log.debug("Removing torrent %s from the core.", torrent_id) 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): if self.torrents.remove(torrent_id, remove_torrent, remove_data):
# Run the plugin hooks for 'post_torrent_remove' # Run the plugin hooks for 'post_torrent_remove'
self.plugins.run_post_torrent_remove(torrent_id) self.plugins.run_post_torrent_remove(torrent_id)
# Emit the torrent_removed signal # Emit the torrent_removed signal
self.torrent_removed(torrent_id) self.torrent_removed(torrent_id)
def export_force_reannounce(self, torrent_id): def export_force_reannounce(self, torrent_ids):
log.debug("Forcing reannouncment to trackers of torrent %s", torrent_id) log.debug("Forcing reannouncment to: %s", torrent_ids)
for torrent_id in torrent_ids:
self.torrents[torrent_id].force_reannounce() self.torrents[torrent_id].force_reannounce()
def export_pause_torrent(self, torrent_id): def export_pause_torrent(self, torrent_ids):
log.debug("Pausing torrent %s", torrent_id) log.debug("Pausing: %s", torrent_ids)
for torrent_id in torrent_ids:
if not self.torrents[torrent_id].pause(): if not self.torrents[torrent_id].pause():
log.warning("Error pausing torrent %s", torrent_id) log.warning("Error pausing torrent %s", torrent_id)
def export_move_torrent(self, torrent_id, dest): def export_move_torrent(self, torrent_ids, dest):
log.debug("Moving torrent %s to %s", torrent_id, 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): if not self.torrents[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)
@ -363,8 +367,9 @@ class Core(
# Emit the 'torrent_all_resumed' signal # Emit the 'torrent_all_resumed' signal
self.torrent_all_resumed() self.torrent_all_resumed()
def export_resume_torrent(self, torrent_id): def export_resume_torrent(self, torrent_ids):
log.debug("Resuming torrent %s", torrent_id) log.debug("Resuming: %s", torrent_ids)
for torrent_id in torrent_ids:
if self.torrents[torrent_id].resume(): if self.torrents[torrent_id].resume():
self.torrent_resumed(torrent_id) self.torrent_resumed(torrent_id)
@ -467,9 +472,10 @@ class Core(
self.plugins.disable_plugin(plugin) self.plugins.disable_plugin(plugin)
return None return None
def export_force_recheck(self, torrent_id): def export_force_recheck(self, torrent_ids):
"""Forces a data recheck on torrent_id""" """Forces a data recheck on torrent_ids"""
return self.torrents.force_recheck(torrent_id) for torrent_id in torrent_ids:
gobject.idle_add(self.torrents.force_recheck, torrent_id)
def export_set_torrent_trackers(self, torrent_id, trackers): def export_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"}]"""

View file

@ -187,12 +187,6 @@ def connected():
return True return True
return False return False
def register_client(port):
get_core().call("register_client", None, port)
def deregister_client():
get_core().call("deregister_client", None)
def shutdown(): def shutdown():
"""Shutdown the core daemon""" """Shutdown the core daemon"""
try: try:
@ -206,6 +200,14 @@ def force_call(block=True):
call also blocks until all callbacks have been dealt with.""" call also blocks until all callbacks have been dealt with."""
get_core().do_multicall(block=block) 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): def add_torrent_file(torrent_files, torrent_options=None):
"""Adds torrent files to the core """Adds torrent files to the core
Expects a list of torrent files 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): def remove_torrent(torrent_ids, remove_torrent=False, remove_data=False):
"""Removes torrent_ids from the core.. Expects a list of torrent_ids""" """Removes torrent_ids from the core.. Expects a list of torrent_ids"""
log.debug("Attempting to removing torrents: %s", torrent_ids) log.debug("Attempting to remove torrents: %s", torrent_ids)
for torrent_id in torrent_ids: get_core().call("remove_torrent", None, torrent_ids, remove_torrent, remove_data)
get_core().call("remove_torrent", None, torrent_id, remove_torrent, remove_data)
def pause_torrent(torrent_ids): def pause_torrent(torrent_ids):
"""Pauses torrent_ids""" """Pauses torrent_ids"""
for torrent_id in torrent_ids: get_core().call("pause_torrent", None, torrent_ids)
get_core().call("pause_torrent", None, torrent_id)
def move_torrent(torrent_ids, folder): def move_torrent(torrent_ids, folder):
"""Pauses torrent_ids""" """Pauses torrent_ids"""
for torrent_id in torrent_ids: get_core().call("move_torrent", None, torrent_ids, folder)
get_core().call("move_torrent", None, torrent_id, folder)
def pause_all_torrents(): def pause_all_torrents():
"""Pauses all torrents""" """Pauses all torrents"""
@ -276,13 +275,11 @@ def resume_all_torrents():
def resume_torrent(torrent_ids): def resume_torrent(torrent_ids):
"""Resume torrent_ids""" """Resume torrent_ids"""
for torrent_id in torrent_ids: get_core().call("resume_torrent", None, torrent_ids)
get_core().call("resume_torrent", None, torrent_id)
def force_reannounce(torrent_ids): def force_reannounce(torrent_ids):
"""Reannounce to trackers""" """Reannounce to trackers"""
for torrent_id in torrent_ids: get_core().call("force_reannounce", None, torrent_ids)
get_core().call("force_reannounce", None, torrent_id)
def get_torrent_status(callback, torrent_id, keys): def get_torrent_status(callback, torrent_id, keys):
"""Builds the status dictionary and returns it""" """Builds the status dictionary and returns it"""
@ -337,8 +334,7 @@ def disable_plugin(plugin):
def force_recheck(torrent_ids): def force_recheck(torrent_ids):
"""Forces a data recheck on torrent_ids""" """Forces a data recheck on torrent_ids"""
for torrent_id in torrent_ids: get_core().call("force_recheck", None, torrent_ids)
get_core().call("force_recheck", None, torrent_id)
def set_torrent_trackers(torrent_id, trackers): def set_torrent_trackers(torrent_id, trackers):
"""Sets the torrents trackers""" """Sets the torrents trackers"""