简单洪水客户
deluge-client的Python项目详细描述
用于洪水的轻量级纯python rpc客户端。 注意,不支持事件,任何来自洪水的额外回复都会扰乱数据流。
要求
- 洪水1.3.x,2.0β
- Python2.7、3.4、3.5、3.6
安装
来自Github(开发):
pip install git+https://github.com/JohnDoee/deluge-client.git#develop
来自PYPI(稳定):
pip install deluge-client
用法
>>> from deluge_client import DelugeRPCClient >>> client = DelugeRPCClient('127.0.0.1', 12345, 'username', 'password') >>> client.connect() >>> client.connected True >>> client.call('core.get_torrents_status', {}, ['name']) {'79816060ea56d56f2a2148cd45705511079f9bca': {'name': 'TPB.AFK.2013.720p.h264-SimonKlose'}} >>> client.core.get_torrents_status({}, ['name']) {'79816060ea56d56f2a2148cd45705511079f9bca': {'name': 'TPB.AFK.2013.720p.h264-SimonKlose'}}
用于在调用时后台程序可能脱机的位置自动重新连接的习惯用法。
import time from deluge_client import DelugeRPCClient, FailedToReconnectException def call_retry(client, method, *args, **kwargs): # We will only try the command 10 times for _ in range(10): try: return client.call(method, *args, **kwargs) except FailedToReconnectException: # 5 second delay between calls time.sleep(5)
习语用法
client = DelugeRPCClient('127.0.0.1', 58846, 'username', 'password', automatic_reconnect=True) # The client has to be online when you start the process, # otherwise you must handle that yourself. client.connect() call_retry(client, 'core.get_torrents_status', {}, ['name'])
许可证
麻省理工学院,请参见许可证