get_stats in core
This commit is contained in:
parent
5d19e72ab4
commit
d6a3c55efa
|
@ -349,6 +349,32 @@ class Core(
|
||||||
# Run the plugin hooks for 'post_torrent_add'
|
# Run the plugin hooks for 'post_torrent_add'
|
||||||
self.plugins.run_post_torrent_add(torrent_id)
|
self.plugins.run_post_torrent_add(torrent_id)
|
||||||
|
|
||||||
|
|
||||||
|
def export_get_stats(self):
|
||||||
|
"""
|
||||||
|
returns: {
|
||||||
|
'download_rate':float(),
|
||||||
|
'upload_rate':float(),
|
||||||
|
'num_connections':int(),
|
||||||
|
'dht_nodes',int(),
|
||||||
|
'max_num_connections':int(),
|
||||||
|
'max_download':float(),
|
||||||
|
'max_upload':float()
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
#dynamic stats:
|
||||||
|
"download_rate":self.session.status().payload_download_rate,
|
||||||
|
"upload_rate":self.session.status().payload_upload_rate,
|
||||||
|
"num_connections":self.session.num_connections(),
|
||||||
|
"dht_nodes":self.session.status().dht_nodes,
|
||||||
|
#max config values:
|
||||||
|
"max_download":self.config["max_download_speed"],
|
||||||
|
"max_upload":self.config["max_upload_speed"],
|
||||||
|
"max_num_connections":self.config["max_connections_global"],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def export_add_torrent_url(self, url, save_path, options):
|
def export_add_torrent_url(self, url, save_path, options):
|
||||||
log.info("Attempting to add url %s", url)
|
log.info("Attempting to add url %s", url)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
from deluge.ui.client import sclient
|
||||||
|
sclient.set_core_uri()
|
||||||
|
|
||||||
|
for key, val in sclient.get_stats().iteritems():
|
||||||
|
print "%s:%s" % (key,val)
|
|
@ -81,7 +81,7 @@ class json_rpc:
|
||||||
* methods : http://dev.deluge-torrent.org/wiki/Development/UiClient#Remoteapi
|
* methods : http://dev.deluge-torrent.org/wiki/Development/UiClient#Remoteapi
|
||||||
"""
|
"""
|
||||||
#extra exposed methods
|
#extra exposed methods
|
||||||
json_exposed = ["update_ui","get_stats","system_listMethods",
|
json_exposed = ["update_ui","system_listMethods",
|
||||||
"get_webui_config","set_webui_config","get_webui_templates"]
|
"get_webui_config","set_webui_config","get_webui_templates"]
|
||||||
cache = {}
|
cache = {}
|
||||||
|
|
||||||
|
@ -139,36 +139,6 @@ class json_rpc:
|
||||||
"system.listMethods() see json/xmlrpc docs"
|
"system.listMethods() see json/xmlrpc docs"
|
||||||
return sclient.list_methods() + self.json_exposed
|
return sclient.list_methods() + self.json_exposed
|
||||||
|
|
||||||
def get_stats(self):
|
|
||||||
"""
|
|
||||||
todo: move to core.
|
|
||||||
returns:
|
|
||||||
{
|
|
||||||
'download_rate':float(),
|
|
||||||
'upload_rate':float(),
|
|
||||||
'max_download':float(),
|
|
||||||
'max_upload':float(),
|
|
||||||
'num_connections':int(),
|
|
||||||
'max_num_connections':int(),
|
|
||||||
'dht_nodes',int()
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
stats = {}
|
|
||||||
|
|
||||||
aclient.get_download_rate(dict_cb('download_rate',stats))
|
|
||||||
aclient.get_upload_rate(dict_cb('upload_rate',stats))
|
|
||||||
aclient.get_config_value(dict_cb('max_download',stats)
|
|
||||||
,"max_download_speed")
|
|
||||||
aclient.get_config_value(dict_cb('max_upload',stats)
|
|
||||||
,"max_upload_speed")
|
|
||||||
aclient.get_num_connections(dict_cb("num_connections",stats))
|
|
||||||
aclient.get_config_value(dict_cb('max_num_connections',stats)
|
|
||||||
,"max_connections_global")
|
|
||||||
aclient.get_dht_nodes(dict_cb('dht_nodes',stats))
|
|
||||||
|
|
||||||
aclient.force_call(block=True)
|
|
||||||
|
|
||||||
return stats
|
|
||||||
|
|
||||||
def update_ui(self, keys ,filter_dict , cache_id = None ):
|
def update_ui(self, keys ,filter_dict , cache_id = None ):
|
||||||
"""
|
"""
|
||||||
|
@ -191,7 +161,7 @@ class json_rpc:
|
||||||
return {
|
return {
|
||||||
"torrents":sclient.get_torrents_status(filter_dict , keys),
|
"torrents":sclient.get_torrents_status(filter_dict , keys),
|
||||||
"filters":filters,
|
"filters":filters,
|
||||||
"stats":self.get_stats(),
|
"stats":sclient.get_stats(),
|
||||||
"cache_id":-1
|
"cache_id":-1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue