diff --git a/deluge/core/core.py b/deluge/core/core.py index b838bd73f..73faac6aa 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -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): diff --git a/deluge/tests/test_stats.py b/deluge/tests/test_stats.py index 97cb7fc64..cbb432b26 100644 --- a/deluge/tests/test_stats.py +++ b/deluge/tests/test_stats.py @@ -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) \ No newline at end of file diff --git a/deluge/tests/test_statusbar.py b/deluge/tests/test_statusbar.py deleted file mode 100644 index 02ce638f8..000000000 --- a/deluge/tests/test_statusbar.py +++ /dev/null @@ -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) - diff --git a/deluge/ui/webui/render.py b/deluge/ui/webui/render.py index 784806918..ae7922dd8 100644 --- a/deluge/ui/webui/render.py +++ b/deluge/ui/webui/render.py @@ -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] diff --git a/deluge/ui/webui/templates/classic/part_stats.html b/deluge/ui/webui/templates/classic/part_stats.html index 5e1c40eff..65af97a2f 100644 --- a/deluge/ui/webui/templates/classic/part_stats.html +++ b/deluge/ui/webui/templates/classic/part_stats.html @@ -2,12 +2,13 @@ $def with (stats)