['Development'] = deluge.ui.client = This is the remote api for deluge. It is used by all deluge user interfaces. [[PageOutline(1,index,inline)]] = sclient = The synchronous api. ''Simple, but blocking the main thread.'' {{{ #!python #get list of torrents from deluge.ui.client import sclient sclient.set_core_uri() torrent_ids = sclient.get_session_state() for id in torrent_ids: print sclient.get_torrent_status(id, ['name','paused','ratio','progress'])]) }}} result: {{{ {'paused': False, 'progress': 100.0, 'ratio': 0.0, 'name': 'autocat_1.0.1.jar'} {'paused': False, 'progress': 100.0, 'ratio': 0.0, 'name': 'autospeed_0.9.0.jar'} {'paused': False, 'progress': 100.0, 'ratio': 0.0, 'name': 'aesmsclient_0.2.1.jar'} }}} = aclient = The asynchronous api. ''Used by rich user interfaces like gtk, or for performance critical batch-calls in webui.'' {{{ #!python #get list of torrents from deluge.ui.client import aclient 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() }}} result: {{{ ['a8d15bd5c740e29f6a0a5bd91547ad5356d01305', 'ca5820f21b316d169c63a953faa3abb1a8abb9f0', 'f2b609578473f6a29d3123ba0897213b3c1bbcda'] {'paused': False, 'progress': 100.0, 'ratio': 0.0, 'name': 'autocat_1.0.1.jar'} {'paused': False, 'progress': 100.0, 'ratio': 0.0, 'name': 'autospeed_0.9.0.jar'} {'paused': False, 'progress': 100.0, 'ratio': 0.0, 'name': 'aesmsclient_0.2.1.jar'} }}} = Client Methods = Non-Core methods on sclient and 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 , sclient and plugins.coreclient.client for sclient, coreclient : 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_file_binary(filename, fdump, options): ''' Core-wrapper. Adds 1 torrent file to the core. Expects fdump as a bytestring (== result of f.read()). '''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_health([callback]): ''' Returns True if we have established incoming connections '''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_storage(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 '''queue_bottom([callback], torrent_ids): ''' '''queue_down([callback], torrent_ids): ''' '''queue_top([callback], torrent_ids): ''' ## Queueing functions ## '''queue_up([callback], torrent_ids): ''' '''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(): ''' 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_prioritize_first_last(torrent_id, value): ''' Sets a higher priority to the first and last pieces '''set_torrent_trackers(torrent_id, trackers): ''' Sets a torrents tracker list. trackers will be [{"url", "tier"}] '''shutdown([callback]): ''' Shutdown the core daemon = Notes = * The available keys for get_torrent_status(id, keys) at the time of writing this: {{{ ['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','peers', "active_time", "seeding_time", "seed_rank", "is_auto_managed", #stats "stop_at_ratio","stop_ratio","remove_at_ratio", #ratio 'tracker_host', 'label' #label-plugin ] }}} * add_torrent_* methods : "options" parameter : available keys , omitted keys default to the deluge preferences. {{{ {"max_download_speed_per_torrent":float(), "max_upload_speed_per_torrent":float(), "max_connections_per_torrent":int(), "max_upload_slots_per_torrent":int(), "prioritize_first_last_pieces":bool(), "add_paused":bool() } }}} * Examples: The sclient/aclient examples use a for each torrent_ids to run get_torrent_status(id, []) . In a real script you would use get_torrent'''s'''_status(torrent_ids, []) = Real world examples = == A scheduler using cron and ui.client == http://dev.deluge-torrent.org/ticket/382#comment:4