简单洪水客户

deluge-client的Python项目详细描述


https://ci.appveyor.com/api/projects/status/8s3g4uucg2xcay6v/branch/develop?svg=true

用于洪水的轻量级纯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'])

许可证

麻省理工学院,请参见许可证

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
字典java cassandra对象映射注释   java定制Solr TokenFilter lemmatizer   字符串从Java文件中读取windows文件名   java如何在Windows上设置StanfordCorenlp服务器以返回文本   java axis2“意外的子元素值”   java使用POI HSSF获取错误   多线程Java等待计时器线程完成   java ForkJoinPool BuffereImage处理风格   从java代码运行Python脚本   java将字节[]转换为短[],使每个短元素包含13位数据   java如何为swing jframe应用程序将代码划分为类   java使用okhttp更改baseurl   java AlertDialog。建设者setView导致堆栈溢出错误   java如何在特定的radius 安卓 studio中接收地址列表?