Version 12 (modified by mvoncken, 16 years ago) (diff) |
---|
deluge.ui.client
This is the remote api for deluge.
It is used by all deluge user interfaces.
sclient
The synchronous api.
Simple, but blocking the main thread.
from deluge.ui.client import sclient #get list of torrents sclient.set_core_uri() torrent_ids = sclient.get_session_state() for id in torrent_ids: print sclient.get_torrent_status(id, [])
aclient
The asynchronous api.
Used by rich user interfaces like gtk, or for performance critical batch-calls in webui.
from deluge.ui.client import aclient #get list of torrents class TestClient: def __init__(self): self.torrent_ids = [] self.torrent_status = [] def cb_session_state(self, torrent_ids): self.torrent_ids = torrent_ids def cb_torrent_status(self, status): self.torrent_status.append(status) def run(self): aclient.get_session_state(self.cb_session_state) aclient.force_call(block=True) print self.torrent_ids for id in self.torrent_ids: aclient.get_torrent_status(self.cb_torrent_status, id , []) aclient.force_call(block=True) for status in self.torrent_status: print status aclient.set_core_uri() t = TestClient() t.run()
Client Methods
Non-Core methods on client/aclient
Generated from docstrings , do not edit
connect_on_new_core(callback):
Connect a callback whenever a new core is connected to.
connect_on_no_core(callback):
Connect a callback whenever the core is disconnected from.
connected():
Returns True if connected to a host, and False if not.
force_call(block):
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_uri():
Get the core URI
is_localhost():
Returns True if core is a localhost
set_core_uri(uri):
Sets the core uri
shutdown():
Shutdown the core daemon
Remote api
Core methods exposed by aclient and sclient.
for sclient : ignore [callback]
for acleint : [callback] is the 1st parameter and refers to a callback method.
Generated from docstrings , do not edit
add_torrent_file(torrent_files, torrent_options):
Adds torrent files to the core Expects a list of torrent files A list of torrent_option dictionaries in the same order of torrent_files
add_torrent_url(url, save_path, options):
block_ip_range(range):
Block an ip range
deregister_client():
De-registers a client with the signal manager.
disable_plugin(plugin):
enable_plugin(plugin):
force_reannounce(torrent_ids):
force_recheck(torrent_ids):
Forces a data recheck on torrent_ids
get_available_plugins([callback]):
Returns a list of plugins available in the core
get_config([callback]):
Get all the preferences as a dictionary
get_config_value([callback], key):
Get the config value for key
get_dht_nodes([callback]):
Returns the number of dht nodes
get_download_rate([callback]):
Returns the payload download rate
get_enabled_plugins([callback]):
Returns a list of enabled plugins in the core
get_listen_port([callback]):
Returns the active listen port
get_num_connections([callback]):
Returns the current number of connections
get_session_state([callback]):
Returns a list of torrent_ids in the session.
get_torrent_status([callback], torrent_id, keys):
get_torrents_status([callback], torrent_ids, keys):
get_upload_rate([callback]):
Returns the payload upload rate
move_torrent(torrent_ids, dest):
pause_all_torrents():
Pause all torrents in the session
pause_torrent(torrent_ids):
ping([callback]):
A method to see if the core is running
register_client(port):
Registers a client with the signal manager so that signals are sent to it.
remove_torrent(torrent_ids, remove_torrent, remove_data):
reset_ip_filter([callback]):
Clears the ip filter
resume_all_torrents([callback]):
Resume all torrents in the session
resume_torrent(torrent_ids):
save_state([callback]):
Save the current session state to file.
set_config(config):
Set the config with values from dictionary
set_torrent_file_priorities(torrent_id, priorities):
Sets a torrents file priorities
set_torrent_max_connections(torrent_id, value):
Sets a torrents max number of connections
set_torrent_max_download_speed(torrent_id, value):
Sets a torrents max download speed
set_torrent_max_upload_slots(torrent_id, value):
Sets a torrents max number of upload slots
set_torrent_max_upload_speed(torrent_id, value):
Sets a torrents max upload speed
set_torrent_private_flag(torrent_id, value):
Sets a torrents private flag
set_torrent_trackers(torrent_id, trackers):
Sets a torrents tracker list. trackers will be [{"url", "tier"}]
Notes
The Possible keys for get_torrent_status(id,keys) are currently:
TORRENT_KEYS = ['name', 'total_size', 'num_files', 'num_pieces', 'piece_length', 'eta', 'ratio', 'file_progress', 'distributed_copies', 'total_done', 'total_uploaded', 'state', 'paused', 'progress', 'next_announce', 'total_payload_download', 'total_payload_upload', 'download_payload_rate', 'upload_payload_rate', 'num_peers', 'num_seeds', 'total_peers', 'total_seeds', 'total_wanted', 'tracker', 'trackers', 'tracker_status', 'save_path', 'files', 'file_priorities', 'compact', 'max_connections', 'max_upload_slots', 'max_download_speed', 'prioritize_first_last', 'private','max_upload_speed','queue']