get_stats+overhead
This commit is contained in:
parent
03e3ccc3a5
commit
35ebf57060
|
@ -360,32 +360,22 @@ class Core(
|
|||
|
||||
def export_get_stats(self):
|
||||
"""
|
||||
returns: {
|
||||
'download_rate':float(),
|
||||
'upload_rate':float(),
|
||||
'num_connections':int(),
|
||||
'dht_nodes',int(),
|
||||
'free_space':long(),
|
||||
'has_incoming_connections':bool(),
|
||||
'max_num_connections':int(),
|
||||
'max_download':float(),
|
||||
'max_upload':float()
|
||||
}
|
||||
document me!!!
|
||||
"""
|
||||
#todo: perf enhancedment:shortcut self.session.status() to a local var.
|
||||
return {
|
||||
stats = self.export_get_session_status(["payload_download_rate", "payload_upload_rate",
|
||||
"dht_nodes", "has_incoming_connections", "download_rate", "upload_rate"])
|
||||
|
||||
stats.update({
|
||||
#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,
|
||||
"free_space":deluge.common.free_space(self.config["download_location"]),
|
||||
"has_incoming_connections":self.session.status().has_incoming_connections,
|
||||
#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"],
|
||||
}
|
||||
})
|
||||
|
||||
return stats
|
||||
|
||||
|
||||
def export_get_session_status(self, keys):
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
#
|
||||
# testing 123..
|
||||
#
|
||||
|
||||
from deluge.ui.client import sclient
|
||||
sclient.set_core_uri()
|
||||
#/init
|
||||
|
||||
print "no-args:"
|
||||
stats = sclient.get_stats()
|
||||
for key in sorted(stats.keys()):
|
||||
print key, ":", stats[key]
|
||||
|
||||
for key, val in sclient.get_stats().iteritems():
|
||||
print "%s:%s" % (key,val)
|
|
@ -1,17 +0,0 @@
|
|||
#
|
||||
# moving and refactoring torrent-filtering from labels-plugin to core.
|
||||
#
|
||||
|
||||
from deluge.ui.client import sclient
|
||||
sclient.set_core_uri()
|
||||
#/init
|
||||
|
||||
print "no-args:"
|
||||
print sclient.get_statusbar()
|
||||
|
||||
print "include-defaults:"
|
||||
print sclient.get_statusbar(True)
|
||||
|
||||
print "no-defaults:"
|
||||
print sclient.get_statusbar(False)
|
||||
|
|
@ -150,9 +150,9 @@ def template_sort_head(id,name):
|
|||
|
||||
def template_part_stats():
|
||||
try:
|
||||
return render.part_stats(get_stats())
|
||||
except Exception:
|
||||
return '[not connected]'
|
||||
return render.part_stats(Storage(sclient.get_stats()))
|
||||
except Exception, e:
|
||||
return str(e)
|
||||
|
||||
def get_config(var):
|
||||
return config[var]
|
||||
|
|
|
@ -2,12 +2,13 @@ $def with (stats)
|
|||
|
||||
<div id='stats_panel'>
|
||||
|
||||
|
||||
<img src="$base/static/images/tango/connections.png" title="$_('Connections')">$stats.num_connections ($deluge_int(stats.max_num_connections))
|
||||
|
||||
<img src="$base/pixmaps/downloading16.png" title="$_('Down Speed')">$stats.download_rate ($deluge_int(stats.max_download))
|
||||
<img src="$base/pixmaps/downloading16.png" title="$_('Down Speed')">$fspeed(stats.payload_download_rate) ($deluge_int(stats.max_download))
|
||||
|
||||
<img src="$base/pixmaps/seeding16.png" title="$_('Up Speed')">$stats.upload_rate ($deluge_int(stats.max_upload))
|
||||
<img src="$base/pixmaps/seeding16.png" title="$_('Up Speed')">$fspeed(stats.payload_upload_rate) ($deluge_int(stats.max_upload))
|
||||
|
||||
<img src="$base/pixmaps/traffic16.png" title="$_('Overhead')">$fspeed(stats.download_rate - stats.payload_download_rate),$fspeed(stats.upload_rate - stats.payload_upload_rate)
|
||||
|
||||
<img src="$base/pixmaps/dht16.png" title="$_('DHT Nodes')">$stats.dht_nodes
|
||||
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
$def with (stats)
|
||||
|
||||
<div id='stats_panel'>
|
||||
|
||||
|
||||
<img src="$base/static/images/tango/connections.png" title="$_('Connections')">$stats.num_connections ($deluge_int(stats.max_num_connections))
|
||||
|
||||
<img src="$base/pixmaps/downloading16.png" title="$_('Down Speed')">$stats.download_rate ($deluge_int(stats.max_download))
|
||||
|
||||
<img src="$base/pixmaps/seeding16.png" title="$_('Up Speed')">$stats.upload_rate ($deluge_int(stats.max_upload))
|
||||
|
||||
<img src="$base/pixmaps/dht16.png" title="$_('DHT Nodes')">$stats.dht_nodes
|
||||
|
||||
<img src="$base/static/images/tango/drive-harddisk.png" title="$_('Disk Space')">$fsize(stats.free_space)
|
||||
|
||||
$if stats.has_incoming_connections:
|
||||
$else:
|
||||
<img src="$base/pixmaps/alert16.png" title="$_('No Incoming Connections')">
|
||||
|
||||
|
||||
</div>
|
|
@ -107,24 +107,6 @@ def getcookie(key, default = None):
|
|||
ck = cookies()
|
||||
return ck.get(key, default)
|
||||
|
||||
def get_stats():
|
||||
stats = Storage(sclient.get_stats())
|
||||
|
||||
stats.download_rate = fspeed(stats.download_rate)
|
||||
stats.upload_rate = fspeed(stats.upload_rate)
|
||||
|
||||
if stats.max_upload < 0:
|
||||
stats.max_upload = _("∞")
|
||||
else:
|
||||
stats.max_upload = "%s KiB/s" % stats.max_upload
|
||||
|
||||
if stats.max_download < 0:
|
||||
stats.max_download = _("∞")
|
||||
else:
|
||||
stats.max_download = "%s KiB/s" % stats.max_download
|
||||
|
||||
return stats
|
||||
|
||||
def enhance_torrent_status(torrent_id, status):
|
||||
"""
|
||||
in: raw torrent_status
|
||||
|
|
Loading…
Reference in New Issue