add get_status_keys()

This commit is contained in:
Martijn Voncken 2008-08-15 20:39:32 +00:00
parent 1170a1cf31
commit 0469d46717
3 changed files with 52 additions and 1 deletions

View File

@ -121,6 +121,16 @@ DEFAULT_PREFS = {
"peer_tos": "0x00", "peer_tos": "0x00",
} }
STATUS_KEYS = ['active_time', 'compact', 'distributed_copies', 'download_payload_rate', 'eta',
'file_priorities', 'file_progress', 'files', 'hash', 'is_auto_managed', 'is_seed', 'max_connections',
'max_download_speed', 'max_upload_slots', 'max_upload_speed', 'message', 'move_on_completed',
'move_on_completed_path', 'name', 'next_announce', 'num_files', 'num_peers', 'num_pieces',
'num_seeds', 'paused', 'peers', 'piece_length', 'prioritize_first_last', 'private', 'progress',
'queue', 'ratio', 'remove_at_ratio', 'save_path', 'seed_rank', 'seeding_time', 'state', 'stop_at_ratio',
'stop_ratio', 'total_done', 'total_payload_download', 'total_payload_upload', 'total_peers',
'total_seeds', 'total_size', 'total_uploaded', 'total_wanted', 'tracker', 'tracker_host',
'tracker_status', 'trackers', 'upload_payload_rate']
class Core( class Core(
ThreadingMixIn, ThreadingMixIn,
SimpleXMLRPCServer.SimpleXMLRPCServer, SimpleXMLRPCServer.SimpleXMLRPCServer,
@ -477,6 +487,12 @@ class Core(
if self.torrents[torrent_id].resume(): if self.torrents[torrent_id].resume():
self.torrent_resumed(torrent_id) self.torrent_resumed(torrent_id)
def export_get_status_keys(self):
"""
returns all possible keys for the keys argument in get_torrent(s)_status.
"""
return STATUS_KEYS + self.plugins.status_fields.keys()
def export_get_torrent_status(self, torrent_id, keys): def export_get_torrent_status(self, torrent_id, keys):
# Build the status dictionary # Build the status dictionary
try: try:

View File

@ -431,7 +431,7 @@ class Torrent:
if distributed_copies < 0: if distributed_copies < 0:
distributed_copies = 0.0 distributed_copies = 0.0
#if you add a key here->add it to core.get_status_keys too. #if you add a key here->add it to core.py STATUS_KEYS too.
full_status = { full_status = {
"distributed_copies": distributed_copies, "distributed_copies": distributed_copies,
"total_done": self.status.total_done, "total_done": self.status.total_done,

View File

@ -0,0 +1,35 @@
#
# moving and refactoring torrent-filtering from labels-plugin to core.
#
#init:
from deluge.ui.client import sclient
sclient.set_core_uri()
torrent_id = sclient.get_session_state()[0]
print torrent_id
#/init
#get_status_keys
#both lines should return the same if all plugins are disabled.
#the 1st should be longer if the label plugin is enabled.
print sorted(sclient.get_torrent_status(torrent_id,[]).keys())
print sorted(sclient.get_status_keys())
#filters on default state fields
print sclient.get_status(["name","state"], {"state":"Paused"})
print sclient.get_status(["name","state"], {"tracker_host":"aelitis.com"})
#plugin status fields:
print sclient.get_status(["name","state"], {"label":"test"})
#special filters:
print sclient.get_status(["name","state"], {"keyword":"az"})