本文整理匯總了Python中deluge_client.DelugeRPCClient.torrent_status方法的典型用法代碼示例。如果您正苦於以下問題:Python DelugeRPCClient.torrent_status方法的具體用法?Python DelugeRPCClient.torrent_status怎麽用?Python DelugeRPCClient.torrent_status使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類deluge_client.DelugeRPCClient
的用法示例。
在下文中一共展示了DelugeRPCClient.torrent_status方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: connect_to_deluge
# 需要導入模塊: from deluge_client import DelugeRPCClient [as 別名]
# 或者: from deluge_client.DelugeRPCClient import torrent_status [as 別名]
def connect_to_deluge():
client = DelugeRPCClient(config.DLGD_HOST, config.DLGD_PORT, config.DLGD_USER, config.DLGD_PASS)
client.connect()
if client.connected: print "Connected to deluge daemon"
from types import MethodType
def add_torr_url(self, url):
return self.call('core.add_torrent_url', wz.urls.url_fix(url), {})
client.add_torr_url = MethodType(add_torr_url, client, DelugeRPCClient)
def add_torr_file(self, file):
f = open(file, 'rb')
filedump = base64.encodestring(f.read())
f.close()
return self.call('core.add_torrent_file', file, filedump, {})
client.add_torr_file = MethodType(add_torr_file, client, DelugeRPCClient)
def add_label(self, label, options={}):
label = normalize_label(label)
self.call('label.add', label)
if options:
if options['move_completed_path']:
options.update({'move_completed': True, 'apply_move_completed': True})
self.call('label.set_options', label, options)
client.add_label = MethodType(add_label, client, DelugeRPCClient)
def label_exist(self, label):
label = normalize_label(label)
if label in self.list_labels():
return True
else:
return False
client.label_exist = MethodType(label_exist, client, DelugeRPCClient)
def list_labels(self):
return self.call('label.get_labels')
client.list_labels = MethodType(list_labels, client, DelugeRPCClient)
def add_tor_label(self, tor_id, label):
return self.call('label.set_torrent', tor_id, normalize_label(label))
client.add_tor_label = MethodType(add_tor_label, client, DelugeRPCClient)
def session_state(self):
return self.call('core.get_session_state')
client.session_state = MethodType(session_state, client, DelugeRPCClient)
def torrent_status(self, tid, fields = {}):
return self.call('core.get_torrent_status', tid, fields)
client.torrent_status = MethodType(torrent_status, client, DelugeRPCClient)
def torrents_status(self, filters = {}, fields = []):
return self.call('core.get_torrents_status', filters, fields)
client.torrents_status = MethodType(torrents_status, client, DelugeRPCClient)
def get_finished(self):
torrs = torrents_status(self)
for k,v in torrs.items():
#print(k,v['name'])
if v['is_finished'] == False:
#print("Removing unfinished: " + v['name'] + " " + str(v['is_finished']))
torrs.pop(k)
elif v['tracker_host'] in config.REMOVE_SEEDS_EXCEPTION_TRACKERS:
#print("Removing exception_tracker: " + v['name'])
torrs.pop(k)
elif not is_all_files_done(v):
#print("Removing not_all_done: " + v['name'])
torrs.pop(k)
return torrs
client.get_finished = MethodType(get_finished, client, DelugeRPCClient)
def remove_finished(self):
for k in get_finished(self):
self.call('core.remove_torrent', k, False)
client.remove_finished = MethodType(remove_finished, client, DelugeRPCClient)
def is_all_files_done(tor):
for i in tor['file_progress']:
if i != 1.0:
return False
return True
return client