Commit 568403a2 authored by Sofa Cough's avatar Sofa Cough
Browse files

update rtorrent compatibility for 0.9.x

parent 1a801631
......@@ -39,7 +39,7 @@ __author__ = "Chris Lucas"
__contact__ = "[email protected]"
__license__ = "MIT"
MIN_RTORRENT_VERSION = (0, 8, 1)
MIN_RTORRENT_VERSION = (0, 9, 0)
MIN_RTORRENT_VERSION_STR = convert_version_tuple_to_str(MIN_RTORRENT_VERSION)
MAX_RETRIES = 5
......@@ -176,7 +176,7 @@ class RTorrent:
if m.is_retriever() and m.is_available(self)]
m = rtorrentlib.rpc.Multicall(self)
m.add("d.multicall", view, "d.get_hash=",
m.add("d.multicall2", '', view, "d.hash=",
*[method.rpc_call + "=" for method in retriever_methods])
results = m.call()[0] # only sent one call, only need first result
......@@ -213,22 +213,22 @@ class RTorrent:
if file_type == "url":
# url strings can be input directly
if start and verbose:
func_name = "load_start_verbose"
func_name = "load.start_verbose"
elif start:
func_name = "load_start"
func_name = "load.start"
elif verbose:
func_name = "load_verbose"
func_name = "load.verbose"
else:
func_name = "load"
func_name = "load.normal"
elif file_type in ["file", "raw"]:
if start and verbose:
func_name = "load_raw_start_verbose"
func_name = "load.raw_start_verbose"
elif start:
func_name = "load_raw_start"
func_name = "load.raw_start"
elif verbose:
func_name = "load_raw_verbose"
func_name = "load.raw_verbose"
else:
func_name = "load_raw"
func_name = "load.raw"
return(func_name)
......@@ -319,7 +319,7 @@ class RTorrent:
func_name = self._get_load_function("raw", start, verbose)
# load torrent
getattr(p, func_name)(new_torrent)
getattr(p, func_name)('', new_torrent)
if verify_load:
new_torrent = None
......@@ -503,75 +503,71 @@ def __check_supported_methods(rt):
methods = [
# RETRIEVERS
Method(RTorrent, 'get_xmlrpc_size_limit', 'get_xmlrpc_size_limit'),
Method(RTorrent, 'get_proxy_address', 'get_proxy_address'),
Method(RTorrent, 'get_split_suffix', 'get_split_suffix'),
Method(RTorrent, 'get_up_limit', 'get_upload_rate'),
Method(RTorrent, 'get_max_memory_usage', 'get_max_memory_usage'),
Method(RTorrent, 'get_max_open_files', 'get_max_open_files'),
Method(RTorrent, 'get_min_peers_seed', 'get_min_peers_seed'),
Method(RTorrent, 'get_use_udp_trackers', 'get_use_udp_trackers'),
Method(RTorrent, 'get_preload_min_size', 'get_preload_min_size'),
Method(RTorrent, 'get_max_uploads', 'get_max_uploads'),
Method(RTorrent, 'get_max_peers', 'get_max_peers'),
Method(RTorrent, 'get_timeout_sync', 'get_timeout_sync'),
Method(RTorrent, 'get_receive_buffer_size', 'get_receive_buffer_size'),
Method(RTorrent, 'get_split_file_size', 'get_split_file_size'),
Method(RTorrent, 'get_dht_throttle', 'get_dht_throttle'),
Method(RTorrent, 'get_max_peers_seed', 'get_max_peers_seed'),
Method(RTorrent, 'get_min_peers', 'get_min_peers'),
Method(RTorrent, 'get_tracker_numwant', 'get_tracker_numwant'),
Method(RTorrent, 'get_max_open_sockets', 'get_max_open_sockets'),
Method(RTorrent, 'get_session', 'get_session'),
Method(RTorrent, 'get_ip', 'get_ip'),
Method(RTorrent, 'get_scgi_dont_route', 'get_scgi_dont_route'),
Method(RTorrent, 'get_hash_read_ahead', 'get_hash_read_ahead'),
Method(RTorrent, 'get_http_cacert', 'get_http_cacert'),
Method(RTorrent, 'get_dht_port', 'get_dht_port'),
Method(RTorrent, 'get_handshake_log', 'get_handshake_log'),
Method(RTorrent, 'get_preload_type', 'get_preload_type'),
Method(RTorrent, 'get_max_open_http', 'get_max_open_http'),
Method(RTorrent, 'get_http_capath', 'get_http_capath'),
Method(RTorrent, 'get_max_downloads_global', 'get_max_downloads_global'),
Method(RTorrent, 'get_name', 'get_name'),
Method(RTorrent, 'get_session_on_completion', 'get_session_on_completion'),
Method(RTorrent, 'get_down_limit', 'get_download_rate'),
Method(RTorrent, 'get_down_total', 'get_down_total'),
Method(RTorrent, 'get_up_rate', 'get_up_rate'),
Method(RTorrent, 'get_hash_max_tries', 'get_hash_max_tries'),
Method(RTorrent, 'get_peer_exchange', 'get_peer_exchange'),
Method(RTorrent, 'get_down_rate', 'get_down_rate'),
Method(RTorrent, 'get_connection_seed', 'get_connection_seed'),
Method(RTorrent, 'get_http_proxy', 'get_http_proxy'),
Method(RTorrent, 'get_stats_preloaded', 'get_stats_preloaded'),
Method(RTorrent, 'get_timeout_safe_sync', 'get_timeout_safe_sync'),
Method(RTorrent, 'get_hash_interval', 'get_hash_interval'),
Method(RTorrent, 'get_port_random', 'get_port_random'),
Method(RTorrent, 'get_directory', 'get_directory'),
Method(RTorrent, 'get_port_open', 'get_port_open'),
Method(RTorrent, 'get_max_file_size', 'get_max_file_size'),
Method(RTorrent, 'get_stats_not_preloaded', 'get_stats_not_preloaded'),
Method(RTorrent, 'get_memory_usage', 'get_memory_usage'),
Method(RTorrent, 'get_connection_leech', 'get_connection_leech'),
Method(RTorrent, 'get_check_hash', 'get_check_hash',
Method(RTorrent, 'get_xmlrpc_size_limit', 'network.xmlrpc.size_limit'),
Method(RTorrent, 'get_proxy_address', 'network.proxy_address'),
Method(RTorrent, 'get_file_split_suffix', 'system.file.split_suffix'),
Method(RTorrent, 'get_global_up_limit', 'throttle.global_up.max_rate'),
Method(RTorrent, 'get_max_memory_usage', 'pieces.memory.max'),
Method(RTorrent, 'get_max_open_files', 'network.max_open_files'),
Method(RTorrent, 'get_min_peers_seed', 'throttle.min_peers.seed'),
Method(RTorrent, 'get_use_udp_trackers', 'trackers.use_udp'),
Method(RTorrent, 'get_preload_min_size', 'pieces.preload.min_size'),
Method(RTorrent, 'get_max_uploads', 'throttle.max_uploads'),
Method(RTorrent, 'get_max_peers', 'throttle.max_peers.normal'),
Method(RTorrent, 'get_timeout_sync', 'pieces.sync.timeout'),
Method(RTorrent, 'get_receive_buffer_size', 'network.receive_buffer.size'),
Method(RTorrent, 'get_split_file_size', 'system.file.split_size'),
Method(RTorrent, 'get_dht_throttle', 'dht.throttle.name'),
Method(RTorrent, 'get_max_peers_seed', 'throttle.max_peers.seed'),
Method(RTorrent, 'get_min_peers', 'throttle.min_peers.normal'),
Method(RTorrent, 'get_tracker_numwant', 'trackers.numwant'),
Method(RTorrent, 'get_max_open_sockets', 'network.max_open_sockets'),
Method(RTorrent, 'get_session_path', 'session.path'),
Method(RTorrent, 'get_local_address', 'network.local_address'),
Method(RTorrent, 'get_scgi_dont_route', 'network.scgi.dont_route'),
Method(RTorrent, 'get_http_cacert', 'network.http.cacert'),
Method(RTorrent, 'get_dht_port', 'dht.port'),
Method(RTorrent, 'get_preload_type', 'pieces.preload.type'),
Method(RTorrent, 'get_http_max_open', 'network.http.max_open'),
Method(RTorrent, 'get_http_capath', 'network.http.capath'),
Method(RTorrent, 'get_max_downloads_global', 'throttle.max_downloads.global'),
Method(RTorrent, 'get_session_name', 'session.name'),
Method(RTorrent, 'get_session_on_completion', 'session.on_completion'),
Method(RTorrent, 'get_down_limit', 'throttle.global_down.max_rate'),
Method(RTorrent, 'get_down_total', 'throttle.global_down.total'),
Method(RTorrent, 'get_up_rate', 'throttle.global_up.rate'),
Method(RTorrent, 'get_peer_exchange', 'protocol.pex'),
Method(RTorrent, 'get_down_rate', 'throttle.global_down.rate'),
Method(RTorrent, 'get_connection_seed', 'protocol.connection.seed'),
Method(RTorrent, 'get_http_proxy_address', 'network.http.proxy_address'),
Method(RTorrent, 'get_stats_preloaded', 'pieces.stats_preloaded'),
Method(RTorrent, 'get_timeout_safe_sync', 'pieces.sync.timeout_safe'),
Method(RTorrent, 'get_port_random', 'network.port_random'),
Method(RTorrent, 'get_directory', 'directory.default'),
Method(RTorrent, 'get_port_open', 'network.port_open'),
Method(RTorrent, 'get_max_file_size', 'system.file.max_size'),
Method(RTorrent, 'get_stats_not_preloaded', 'pieces.stats_not_preloaded'),
Method(RTorrent, 'get_memory_usage', 'pieces.memory.current'),
Method(RTorrent, 'get_connection_leech', 'protocol.connection.leech'),
Method(RTorrent, 'get_hash_on_completion', 'pieces.hash.on_completion',
boolean=True,
),
Method(RTorrent, 'get_session_lock', 'get_session_lock'),
Method(RTorrent, 'get_preload_required_rate', 'get_preload_required_rate'),
Method(RTorrent, 'get_max_uploads_global', 'get_max_uploads_global'),
Method(RTorrent, 'get_send_buffer_size', 'get_send_buffer_size'),
Method(RTorrent, 'get_port_range', 'get_port_range'),
Method(RTorrent, 'get_max_downloads_div', 'get_max_downloads_div'),
Method(RTorrent, 'get_max_uploads_div', 'get_max_uploads_div'),
Method(RTorrent, 'get_safe_sync', 'get_safe_sync'),
Method(RTorrent, 'get_bind', 'get_bind'),
Method(RTorrent, 'get_up_total', 'get_up_total'),
Method(RTorrent, 'get_session_lock', 'session.use_lock'),
Method(RTorrent, 'get_preload_min_rate', 'pieces.preload.min_rate'),
Method(RTorrent, 'get_max_uploads_global', 'throttle.max_uploads.global'),
Method(RTorrent, 'get_send_buffer_size', 'network.send_buffer.size'),
Method(RTorrent, 'get_port_range', 'network.port_range'),
Method(RTorrent, 'get_max_downloads_div', 'throttle.max_downloads.div'),
Method(RTorrent, 'get_max_uploads_div', 'throttle.max_uploads.div'),
Method(RTorrent, 'get_always_safe_sync', 'pieces.sync.always_safe'),
Method(RTorrent, 'get_bind_address', 'network.bind_address'),
Method(RTorrent, 'get_up_total', 'throttle.global_up.total'),
Method(RTorrent, 'get_client_version', 'system.client_version'),
Method(RTorrent, 'get_library_version', 'system.library_version'),
Method(RTorrent, 'get_api_version', 'system.api_version',
min_version=(0, 9, 1)
),
Method(RTorrent, "get_system_time", "system.time",
Method(RTorrent, 'get_system_time', 'system.time',
docstring="""Get the current time of the system rTorrent is running on
@return: time (posix)
......@@ -579,84 +575,79 @@ methods = [
),
# MODIFIERS
Method(RTorrent, 'set_http_proxy', 'set_http_proxy'),
Method(RTorrent, 'set_max_memory_usage', 'set_max_memory_usage'),
Method(RTorrent, 'set_max_file_size', 'set_max_file_size'),
Method(RTorrent, 'set_bind', 'set_bind',
Method(RTorrent, 'set_http_proxy_address', 'network.http.proxy_address.set'),
Method(RTorrent, 'set_max_memory_usage', 'pieces.memory.max.set'),
Method(RTorrent, 'set_max_file_size', 'system.file.max_size.set'),
Method(RTorrent, 'set_bind_address', 'network.bind_address.set',
docstring="""Set address bind
@param arg: ip address
@type arg: str
""",
),
Method(RTorrent, 'set_up_limit', 'set_upload_rate',
Method(RTorrent, 'set_up_limit', 'throttle.global_up.max_rate.set',
docstring="""Set global upload limit (in bytes)
@param arg: speed limit
@type arg: int
""",
),
Method(RTorrent, 'set_port_random', 'set_port_random'),
Method(RTorrent, 'set_connection_leech', 'set_connection_leech'),
Method(RTorrent, 'set_tracker_numwant', 'set_tracker_numwant'),
Method(RTorrent, 'set_max_peers', 'set_max_peers'),
Method(RTorrent, 'set_min_peers', 'set_min_peers'),
Method(RTorrent, 'set_max_uploads_div', 'set_max_uploads_div'),
Method(RTorrent, 'set_max_open_files', 'set_max_open_files'),
Method(RTorrent, 'set_max_downloads_global', 'set_max_downloads_global'),
Method(RTorrent, 'set_session_lock', 'set_session_lock'),
Method(RTorrent, 'set_session', 'set_session'),
Method(RTorrent, 'set_split_suffix', 'set_split_suffix'),
Method(RTorrent, 'set_hash_interval', 'set_hash_interval'),
Method(RTorrent, 'set_handshake_log', 'set_handshake_log'),
Method(RTorrent, 'set_port_range', 'set_port_range'),
Method(RTorrent, 'set_min_peers_seed', 'set_min_peers_seed'),
Method(RTorrent, 'set_scgi_dont_route', 'set_scgi_dont_route'),
Method(RTorrent, 'set_preload_min_size', 'set_preload_min_size'),
Method(RTorrent, 'set_log.tracker', 'set_log.tracker'),
Method(RTorrent, 'set_max_uploads_global', 'set_max_uploads_global'),
Method(RTorrent, 'set_down_limit', 'set_download_rate',
Method(RTorrent, 'set_port_random', 'network.port_random.set'),
Method(RTorrent, 'set_connection_leech', 'protocol.connection.leech.set'),
Method(RTorrent, 'set_tracker_numwant', 'trackers.numwant.set'),
Method(RTorrent, 'set_max_peers', 'throttle.max_peers.normal.set'),
Method(RTorrent, 'set_min_peers', 'throttle.min_peers.normal.set'),
Method(RTorrent, 'set_max_uploads_div', 'throttle.max_uploads.div.set'),
Method(RTorrent, 'set_max_open_files', 'network.max_open_files.set'),
Method(RTorrent, 'set_max_downloads_global', 'throttle.max_downloads.global.set'),
Method(RTorrent, 'set_session_lock', 'session.use_lock.set'),
Method(RTorrent, 'set_session_path', 'session.path.set'),
Method(RTorrent, 'set_file_split_suffix', 'system.file.split_suffix.set'),
Method(RTorrent, 'set_port_range', 'network.port_range.set'),
Method(RTorrent, 'set_min_peers_seed', 'throttle.min_peers.seed.set'),
Method(RTorrent, 'set_scgi_dont_route', 'network.scgi.dont_route.set'),
Method(RTorrent, 'set_preload_min_size', 'pieces.preload.min_size.set'),
Method(RTorrent, 'set_max_uploads_global', 'throttle.max_uploads.global.set'),
Method(RTorrent, 'set_down_limit', 'throttle.global_down.max_rate.set',
docstring="""Set global download limit (in bytes)
@param arg: speed limit
@type arg: int
""",
),
Method(RTorrent, 'set_preload_required_rate', 'set_preload_required_rate'),
Method(RTorrent, 'set_hash_read_ahead', 'set_hash_read_ahead'),
Method(RTorrent, 'set_max_peers_seed', 'set_max_peers_seed'),
Method(RTorrent, 'set_max_uploads', 'set_max_uploads'),
Method(RTorrent, 'set_session_on_completion', 'set_session_on_completion'),
Method(RTorrent, 'set_max_open_http', 'set_max_open_http'),
Method(RTorrent, 'set_directory', 'set_directory'),
Method(RTorrent, 'set_http_cacert', 'set_http_cacert'),
Method(RTorrent, 'set_dht_throttle', 'set_dht_throttle'),
Method(RTorrent, 'set_hash_max_tries', 'set_hash_max_tries'),
Method(RTorrent, 'set_proxy_address', 'set_proxy_address'),
Method(RTorrent, 'set_split_file_size', 'set_split_file_size'),
Method(RTorrent, 'set_receive_buffer_size', 'set_receive_buffer_size'),
Method(RTorrent, 'set_use_udp_trackers', 'set_use_udp_trackers'),
Method(RTorrent, 'set_connection_seed', 'set_connection_seed'),
Method(RTorrent, 'set_xmlrpc_size_limit', 'set_xmlrpc_size_limit'),
Method(RTorrent, 'set_xmlrpc_dialect', 'set_xmlrpc_dialect'),
Method(RTorrent, 'set_safe_sync', 'set_safe_sync'),
Method(RTorrent, 'set_http_capath', 'set_http_capath'),
Method(RTorrent, 'set_send_buffer_size', 'set_send_buffer_size'),
Method(RTorrent, 'set_max_downloads_div', 'set_max_downloads_div'),
Method(RTorrent, 'set_name', 'set_name'),
Method(RTorrent, 'set_port_open', 'set_port_open'),
Method(RTorrent, 'set_timeout_sync', 'set_timeout_sync'),
Method(RTorrent, 'set_peer_exchange', 'set_peer_exchange'),
Method(RTorrent, 'set_ip', 'set_ip',
Method(RTorrent, 'set_preload_min_rate', 'pieces.preload.min_rate.set'),
Method(RTorrent, 'set_max_peers_seed', 'throttle.max_peers.seed.set'),
Method(RTorrent, 'set_max_uploads', 'throttle.max_uploads.set'),
Method(RTorrent, 'set_session_on_completion', 'session.on_completion.set'),
Method(RTorrent, 'set_max_open_http', 'network.http.max_open.set'),
Method(RTorrent, 'set_directory', 'directory.default.set'),
Method(RTorrent, 'set_http_cacert', 'network.http.cacert.set'),
Method(RTorrent, 'set_dht_throttle', 'dht.throttle.name.set'),
Method(RTorrent, 'set_proxy_address', 'network.proxy_address.set'),
Method(RTorrent, 'set_split_file_size', 'system.file.split_size.set'),
Method(RTorrent, 'set_receive_buffer_size', 'network.receive_buffer.size.set'),
Method(RTorrent, 'set_use_udp_trackers', 'trackers.use_udp.set'),
Method(RTorrent, 'set_connection_seed', 'protocol.connection.seed.set'),
Method(RTorrent, 'set_xmlrpc_size_limit', 'network.xmlrpc.size_limit.set'),
Method(RTorrent, 'set_xmlrpc_dialect', 'network.xmlrpc.dialect.set'),
Method(RTorrent, 'set_always_safe_sync', 'pieces.sync.always_safe.set'),
Method(RTorrent, 'set_http_capath', 'network.http.capath.set'),
Method(RTorrent, 'set_send_buffer_size', 'network.send_buffer.size.set'),
Method(RTorrent, 'set_max_downloads_div', 'throttle.max_downloads.div.set'),
Method(RTorrent, 'set_session_name', 'session.name.set'),
Method(RTorrent, 'set_port_open', 'network.port_open.set'),
Method(RTorrent, 'set_timeout_sync', 'pieces.sync.timeout.set'),
Method(RTorrent, 'set_peer_exchange', 'protocol.pex.set'),
Method(RTorrent, 'set_local_address', 'network.local_address.set',
docstring="""Set IP
@param arg: ip address
@type arg: str
""",
),
Method(RTorrent, 'set_timeout_safe_sync', 'set_timeout_safe_sync'),
Method(RTorrent, 'set_preload_type', 'set_preload_type'),
Method(RTorrent, 'set_check_hash', 'set_check_hash',
Method(RTorrent, 'set_timeout_safe_sync', 'pieces.sync.timeout_safe.set'),
Method(RTorrent, 'set_preload_type', 'pieces.preload.type.set'),
Method(RTorrent, 'set_hash_on_completion', 'pieces.hash.on_completion.set',
docstring="""Enable/Disable hash checking on finished torrents
@param arg: True to enable, False to disable
......
......@@ -59,29 +59,29 @@ class File:
methods = [
# RETRIEVERS
Method(File, 'get_last_touched', 'f.get_last_touched'),
Method(File, 'get_range_second', 'f.get_range_second'),
Method(File, 'get_size_bytes', 'f.get_size_bytes'),
Method(File, 'get_priority', 'f.get_priority'),
Method(File, 'get_match_depth_next', 'f.get_match_depth_next'),
Method(File, 'get_last_touched', 'f.last_touched'),
Method(File, 'get_range_second', 'f.range_second'),
Method(File, 'get_size_bytes', 'f.size_bytes'),
Method(File, 'get_priority', 'f.priority'),
Method(File, 'get_match_depth_next', 'f.match_depth_next'),
Method(File, 'is_resize_queued', 'f.is_resize_queued',
boolean=True,
),
Method(File, 'get_range_first', 'f.get_range_first'),
Method(File, 'get_match_depth_prev', 'f.get_match_depth_prev'),
Method(File, 'get_path', 'f.get_path'),
Method(File, 'get_completed_chunks', 'f.get_completed_chunks'),
Method(File, 'get_path_components', 'f.get_path_components'),
Method(File, 'get_range_first', 'f.range_first'),
Method(File, 'get_match_depth_prev', 'f.match_depth_prev'),
Method(File, 'get_path', 'f.path'),
Method(File, 'get_completed_chunks', 'f.completed_chunks'),
Method(File, 'get_path_components', 'f.path_components'),
Method(File, 'is_created', 'f.is_created',
boolean=True,
),
Method(File, 'is_open', 'f.is_open',
boolean=True,
),
Method(File, 'get_size_chunks', 'f.get_size_chunks'),
Method(File, 'get_offset', 'f.get_offset'),
Method(File, 'get_frozen_path', 'f.get_frozen_path'),
Method(File, 'get_path_depth', 'f.get_path_depth'),
Method(File, 'get_size_chunks', 'f.size_chunks'),
Method(File, 'get_offset', 'f.offset'),
Method(File, 'get_frozen_path', 'f.frozen_path'),
Method(File, 'get_path_depth', 'f.path_depth'),
Method(File, 'is_create_queued', 'f.is_create_queued',
boolean=True,
),
......
......@@ -76,7 +76,7 @@ class Group:
m = rtorrentlib.rpc.Multicall(self)
self.multicall_add(
m, 'system.method.set',
m, 'method.set', '',
self._get_prefix() + 'command',
*methods
)
......
......@@ -60,39 +60,38 @@ methods = [
Method(Peer, 'is_preferred', 'p.is_preferred',
boolean=True,
),
Method(Peer, 'get_down_rate', 'p.get_down_rate'),
Method(Peer, 'get_down_rate', 'p.down_rate'),
Method(Peer, 'is_unwanted', 'p.is_unwanted',
boolean=True,
),
Method(Peer, 'get_peer_total', 'p.get_peer_total'),
Method(Peer, 'get_peer_rate', 'p.get_peer_rate'),
Method(Peer, 'get_port', 'p.get_port'),
Method(Peer, 'get_peer_total', 'p.peer_total'),
Method(Peer, 'get_peer_rate', 'p.peer_rate'),
Method(Peer, 'get_port', 'p.port'),
Method(Peer, 'is_snubbed', 'p.is_snubbed',
boolean=True,
),
Method(Peer, 'get_id_html', 'p.get_id_html'),
Method(Peer, 'get_up_rate', 'p.get_up_rate'),
Method(Peer, 'get_id_html', 'p.id_html'),
Method(Peer, 'get_up_rate', 'p.up_rate'),
Method(Peer, 'is_banned', 'p.banned',
boolean=True,
),
Method(Peer, 'get_completed_percent', 'p.get_completed_percent'),
Method(Peer, 'completed_percent', 'p.completed_percent'),
Method(Peer, 'get_id', 'p.get_id'),
Method(Peer, 'get_completed_percent', 'p.completed_percent'),
Method(Peer, 'get_id', 'p.id'),
Method(Peer, 'is_obfuscated', 'p.is_obfuscated',
boolean=True,
),
Method(Peer, 'get_down_total', 'p.get_down_total'),
Method(Peer, 'get_client_version', 'p.get_client_version'),
Method(Peer, 'get_address', 'p.get_address'),
Method(Peer, 'get_down_total', 'p.down_total'),
Method(Peer, 'get_client_version', 'p.client_version'),
Method(Peer, 'get_address', 'p.address'),
Method(Peer, 'is_incoming', 'p.is_incoming',
boolean=True,
),
Method(Peer, 'is_encrypted', 'p.is_encrypted',
boolean=True,
),
Method(Peer, 'get_options_str', 'p.get_options_str'),
Method(Peer, 'get_options_str', 'p.options_str'),
Method(Peer, 'get_client_version', 'p.client_version'),
Method(Peer, 'get_up_total', 'p.get_up_total'),
Method(Peer, 'get_up_total', 'p.up_total'),
# MODIFIERS
]
......@@ -35,12 +35,11 @@ def get_varname(rpc_call):
name will be 'down_rate'
"""
# extract variable name from xmlrpc func name
r = re.search(
"([ptdf]\.|system\.|get\_|is\_|set\_)+([^=]*)", rpc_call, re.I)
r = re.match(r'(?:[ptdf]\.)?(.+?)(?:\.set)?$', rpc_call)
if r:
return(r.groups()[-1])
else:
return(None)
return r.group(1)
return None
def _handle_unavailable_rpc_method(method, rt_obj):
......@@ -91,7 +90,8 @@ class Method:
def _get_method_type(self):
"""Determine whether method is a modifier or a retriever"""
if self.method_name[:4] == "set_": return('m') # modifier
if self.method_name[:4] == "set_":
return('m') # modifier
else:
return('r') # retriever
......
......@@ -136,7 +136,7 @@ class Torrent:
results = m.call()[0] # only sent one call, only need first result
offset_method_index = retriever_methods.index(
rtorrentlib.rpc.find_method("f.get_offset"))
rtorrentlib.rpc.find_method("f.offset"))
# make a list of the offsets of all the files, sort appropriately
offset_list = sorted([r[offset_method_index] for r in results])
......@@ -301,7 +301,7 @@ class Torrent:
m = rtorrentlib.rpc.Multicall(self)
field = "custom{0}".format(key)
self.multicall_add(m, "d.get_{0}".format(field))
self.multicall_add(m, "d.{0}".format(field))
setattr(self, field, m.call()[-1])
return (getattr(self, field))
......@@ -323,7 +323,7 @@ class Torrent:
self._assert_custom_key_valid(key)
m = rtorrentlib.rpc.Multicall(self)
self.multicall_add(m, "d.set_custom{0}".format(key), value)
self.multicall_add(m, "d.custom{0}.set".format(key), value)
return(m.call()[-1])
......@@ -352,7 +352,7 @@ class Torrent:
@note: Variable where the result for this method is stored Torrent.hash_checking_queued"""
m = rtorrentlib.rpc.Multicall(self)
self.multicall_add(m, "d.get_hashing")
self.multicall_add(m, "d.hashing")
self.multicall_add(m, "d.is_hash_checking")
results = m.call()
......@@ -394,86 +394,86 @@ methods = [
Method(Torrent, 'is_hash_checking', 'd.is_hash_checking',
boolean=True,
),
Method(Torrent, 'get_peers_max', 'd.get_peers_max'),
Method(Torrent, 'get_tracker_focus', 'd.get_tracker_focus'),
Method(Torrent, 'get_skip_total', 'd.get_skip_total'),
Method(Torrent, 'get_state', 'd.get_state'),
Method(Torrent, 'get_peer_exchange', 'd.get_peer_exchange'),
Method(Torrent, 'get_down_rate', 'd.get_down_rate'),
Method(Torrent, 'get_connection_seed', 'd.get_connection_seed'),
Method(Torrent, 'get_uploads_max', 'd.get_uploads_max'),
Method(Torrent, 'get_priority_str', 'd.get_priority_str'),
Method(Torrent, 'get_peers_max', 'd.peers_max'),
Method(Torrent, 'get_tracker_focus', 'd.tracker_focus'),
Method(Torrent, 'get_skip_total', 'd.skip_total'),
Method(Torrent, 'get_state', 'd.state'),
Method(Torrent, 'get_peer_exchange', 'd.peer_exchange'),
Method(Torrent, 'get_down_rate', 'd.down_rate'),
Method(Torrent, 'get_connection_seed', 'd.connection_seed'),
Method(Torrent, 'get_uploads_max', 'd.uploads_max'),
Method(Torrent, 'get_priority_str', 'd.priority_str'),
Method(Torrent, 'is_open', 'd.is_open',
boolean=True,
),
Method(Torrent, 'get_peers_min', 'd.get_peers_min'),
Method(Torrent, 'get_peers_complete', 'd.get_peers_complete'),
Method(Torrent, 'get_tracker_numwant', 'd.get_tracker_numwant'),
Method(Torrent, 'get_connection_current', 'd.get_connection_current'),
Method(Torrent, 'is_complete', 'd.get_complete',
Method(Torrent, 'get_peers_min', 'd.peers_min'),
Method(Torrent, 'get_peers_complete', 'd.peers_complete'),
Method(Torrent, 'get_tracker_numwant', 'd.tracker_numwant'),
Method(Torrent, 'get_connection_current', 'd.connection_current'),
Method(Torrent, 'is_complete', 'd.complete',
boolean=True,
),
Method(Torrent, 'get_peers_connected', 'd.get_peers_connected'),
Method(Torrent, 'get_chunk_size', 'd.get_chunk_size'),
Method(Torrent, 'get_state_counter', 'd.get_state_counter'),
Method(Torrent, 'get_base_filename', 'd.get_base_filename'),
Method(Torrent, 'get_state_changed', 'd.get_state_changed'),
Method(Torrent, 'get_peers_not_connected', 'd.get_peers_not_connected'),
Method(Torrent, 'get_directory', 'd.get_directory'),
Method(Torrent, 'get_peers_connected', 'd.peers_connected'),
Method(Torrent, 'get_chunk_size', 'd.chunk_size'),
Method(Torrent, 'get_state_counter', 'd.state_counter'),
Method(Torrent, 'get_base_filename', 'd.base_filename'),
Method(Torrent, 'get_state_changed', 'd.state_changed'),
Method(Torrent, 'get_peers_not_connected', 'd.peers_not_connected'),
Method(Torrent, 'get_directory', 'd.directory'),
Method(Torrent, 'is_incomplete', 'd.incomplete',
boolean=True,
),
Method(Torrent, 'get_tracker_size', 'd.get_tracker_size'),
Method(Torrent, 'get_tracker_size', 'd.tracker_size'),
Method(Torrent, 'is_multi_file', 'd.is_multi_file',
boolean=True,
),
Method(Torrent, 'get_local_id', 'd.get_local_id'),
Method(Torrent, 'get_ratio', 'd.get_ratio',
Method(Torrent, 'get_local_id', 'd.local_id'),
Method(Torrent, 'get_ratio', 'd.ratio',
post_process_func=lambda x: x / 1000.0,
),
Method(Torrent, 'get_loaded_file', 'd.get_loaded_file'),
Method(Torrent, 'get_max_file_size', 'd.get_max_file_size'),
Method(Torrent, 'get_size_chunks', 'd.get_size_chunks'),
Method(Torrent, 'get_loaded_file', 'd.loaded_file'),
Method(Torrent, 'get_max_file_size', 'd.max_file_size'),
Method(Torrent, 'get_size_chunks', 'd.size_chunks'),
Method(Torrent, 'is_pex_active', 'd.is_pex_active',
boolean=True,
),
Method(Torrent, 'get_hashing', 'd.get_hashing'),
Method(Torrent, 'get_bitfield', 'd.get_bitfield'),
Method(Torrent, 'get_local_id_html', 'd.get_local_id_html'),
Method(Torrent, 'get_connection_leech', 'd.get_connection_leech'),
Method(Torrent, 'get_peers_accounted', 'd.get_peers_accounted'),
Method(Torrent, 'get_message', 'd.get_message'),
Method(Torrent, 'get_hashing', 'd.hashing'),
Method(Torrent, 'get_bitfield', 'd.bitfield'),
Method(Torrent, 'get_local_id_html', 'd.local_id_html'),
Method(Torrent, 'get_connection_leech', 'd.connection_leech'),
Method(Torrent, 'get_peers_accounted', 'd.peers_accounted'),
Method(Torrent, 'get_message', 'd.message'),
Method(Torrent, 'is_active', 'd.is_active',
boolean=True,
),
Method(Torrent, 'get_size_bytes', 'd.get_size_bytes'),