Author: andar
Revision: 6062
Log:
#496: Remove deprecated functions in favour of get_session_status()
Diff:
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-12-25 21:27:07 UTC (rev 6061)
+++ trunk/ChangeLog 2009-12-25 21:29:47 UTC (rev 6062)
@@ -2,9 +2,8 @@
==== Core ====
* Implement #1063 option to delete torrent file copy on torrent removal -
patch from Ghent
* Implement #457 progress bars for folders
+ * #496: Remove deprecated functions in favour of get_session_status()
-==== GtkUI ====
-
=== Deluge 1.2.0 (In Development) ===
==== Core ====
* Implement new RPC protocol DelugeRPC replacing XMLRPC
Modified: trunk/deluge/core/core.py
===================================================================
--- trunk/deluge/core/core.py 2009-12-25 21:27:07 UTC (rev 6061)
+++ trunk/deluge/core/core.py 2009-12-25 21:29:47 UTC (rev 6062)
@@ -289,28 +289,6 @@
return self.torrentmanager.remove(torrent_id, remove_data)
@export
- def get_stats(self):
- """
- Deprecated: please use get_session_status()
-
- """
- warnings.warn("Use get_session_status() instead of get_stats()",
DeprecationWarning)
- stats = self.get_session_status(["payload_download_rate",
"payload_upload_rate",
- "dht_nodes", "has_incoming_connections", "download_rate",
"upload_rate"])
-
- stats.update({
- #dynamic stats:
- "num_connections":self.session.num_connections(),
-
"free_space":deluge.common.free_space(self.config["download_location"]),
- #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
-
- @export
def get_session_status(self, keys):
"""
Gets the session status values for 'keys', these keys are taking
@@ -491,24 +469,6 @@
return self.session.num_connections()
@export
- def get_dht_nodes(self):
- """Returns the number of dht nodes"""
- warnings.warn("Use get_session_status().", DeprecationWarning)
- return self.session.status().dht_nodes
-
- @export
- def get_download_rate(self):
- """Returns the payload download rate"""
- warnings.warn("Use get_session_status().", DeprecationWarning)
- return self.session.status().payload_download_rate
-
- @export
- def get_upload_rate(self):
- """Returns the payload upload rate"""
- warnings.warn("Use get_session_status().", DeprecationWarning)
- return self.session.status().payload_upload_rate
-
- @export
def get_available_plugins(self):
"""Returns a list of plugins available in the core"""
return self.pluginmanager.get_available_plugins()
@@ -606,12 +566,6 @@
return self.torrentmanager[torrent_id].set_move_completed_path(value)
@export
- def get_health(self):
- """Returns True if we have established incoming connections"""
- warnings.warn("Use get_session_status().", DeprecationWarning)
- return self.session.status().has_incoming_connections
-
- @export
def get_path_size(self, path):
"""Returns the size of the file or folder 'path' and -1 if the path is
unaccessible (non-existent or insufficient privs)"""
Modified: trunk/deluge/ui/console/statusbars.py
===================================================================
--- trunk/deluge/ui/console/statusbars.py 2009-12-25 21:27:07 UTC (rev
6061)
+++ trunk/deluge/ui/console/statusbars.py 2009-12-25 21:29:47 UTC (rev
6062)
@@ -64,11 +64,6 @@
if not self.__core_config_ready:
return
- if self.config["dht"]:
- def on_get_dht_nodes(result):
- self.dht = result
- client.core.get_dht_nodes().addCallback(on_get_dht_nodes)
-
def on_get_num_connections(result):
self.connections = result
client.core.get_num_connections().addCallback(on_get_num_connections)
@@ -76,13 +71,21 @@
def on_get_session_status(status):
self.upload = deluge.common.fsize(status["payload_upload_rate"])
self.download =
deluge.common.fsize(status["payload_download_rate"])
+ if "dht_nodes" in status:
+ self.dht = status["dht_nodes"]
+
self.update_statusbars()
- client.core.get_session_status([
+ keys = [
"payload_upload_rate",
- "payload_download_rate"]).addCallback(on_get_session_status)
+ "payload_download_rate"]
+ if self.config["dht"]:
+ keys.append("dht_nodes")
+ client.core.get_session_status(keys).addCallback(on_get_session_status)
+
+
def update_statusbars(self):
# Update the topbar string
self.screen.topbar = "{!status!}Deluge %s Console - " %
deluge.common.get_version()
Modified: trunk/deluge/ui/gtkui/statusbar.py
===================================================================
--- trunk/deluge/ui/gtkui/statusbar.py 2009-12-25 21:27:07 UTC (rev 6061)
+++ trunk/deluge/ui/gtkui/statusbar.py 2009-12-25 21:29:47 UTC (rev 6062)
@@ -195,7 +195,6 @@
client.core.get_config_value(
"max_upload_speed").addCallback(self._on_max_upload_speed)
client.core.get_config_value("dht").addCallback(self._on_dht)
- client.core.get_health().addCallback(self._on_get_health)
self.send_status_request()
@@ -266,18 +265,20 @@
def send_status_request(self):
# Sends an async request for data from the core
client.core.get_num_connections().addCallback(self._on_get_num_connections)
- if self.dht_status:
- client.core.get_dht_nodes().addCallback(self._on_get_dht_nodes)
- client.core.get_session_status([
+ keys = [
"upload_rate",
"download_rate",
"payload_upload_rate",
- "payload_download_rate"]).addCallback(self._on_get_session_status)
+ "payload_download_rate"]
+ if self.dht_status:
+ keys.append("dht_nodes")
+
if not self.health:
- # Only request health status while False
- client.core.get_health().addCallback(self._on_get_health)
+ keys.append("has_incoming_connections")
+
client.core.get_session_status(keys).addCallback(self._on_get_session_status)
+
def on_configvaluechanged_event(self, key, value):
"""
This is called when we receive a ConfigValueChangedEvent from
@@ -295,16 +296,12 @@
self.num_connections = num_connections
self.update_connections_label()
- def _on_get_dht_nodes(self, dht_nodes):
- self.dht_nodes = dht_nodes
- self.update_dht_label()
-
def _on_dht(self, value):
self.dht_status = value
if value:
self.hbox.pack_start(
self.dht_item.get_eventbox(), expand=False, fill=False)
- client.core.get_dht_nodes().addCallback(self._on_get_dht_nodes)
+ self.send_status_request()
else:
self.remove_item(self.dht_item)
@@ -317,6 +314,15 @@
self.update_upload_label()
self.update_traffic_label()
+ if "dht_nodes" in status:
+ self.dht_nodes = status["dht_nodes"]
+ self.update_dht_label()
+
+ if "has_incoming_connections" in status:
+ self.health = status["has_incoming_connections"]
+ if self.health:
+ self.remove_item(self.health_item)
+
def _on_max_download_speed(self, max_download_speed):
self.max_download_speed = max_download_speed
self.update_download_label()
@@ -325,11 +331,6 @@
self.max_upload_speed = max_upload_speed
self.update_upload_label()
- def _on_get_health(self, value):
- self.health = value
- if self.health:
- self.remove_item(self.health_item)
-
def update_connections_label(self):
# Set the max connections label
if self.max_connections < 0:
Modified: trunk/deluge/ui/gtkui/systemtray.py
===================================================================
--- trunk/deluge/ui/gtkui/systemtray.py 2009-12-25 21:27:07 UTC (rev 6061)
+++ trunk/deluge/ui/gtkui/systemtray.py 2009-12-25 21:29:47 UTC (rev 6062)
@@ -169,8 +169,9 @@
self.tray.set_visible(False)
def send_status_request(self):
- client.core.get_download_rate().addCallback(self._on_get_download_rate)
- client.core.get_upload_rate().addCallback(self._on_get_upload_rate)
+ client.core.get_session_status([
+ "payload_upload_rate",
+ "payload_download_rate"]).addCallback(self._on_get_session_status)
def config_value_changed(self, key, value):
"""This is called when we received a config_value_changed signal from
@@ -184,16 +185,14 @@
self.max_download_speed = max_download_speed
self.build_tray_bwsetsubmenu()
- def _on_get_download_rate(self, download_rate):
- self.download_rate = deluge.common.fsize(download_rate)
-
def _on_max_upload_speed(self, max_upload_speed):
if self.max_upload_speed != max_upload_speed:
self.max_upload_speed = max_upload_speed
self.build_tray_bwsetsubmenu()
- def _on_get_upload_rate(self, upload_rate):
- self.upload_rate = deluge.common.fsize(upload_rate)
+ def _on_get_session_status(self, status):
+ self.download_rate =
deluge.common.fsize(status["payload_download_rate"])
+ self.upload_rate = deluge.common.fsize(status["payload_upload_rate"])
def update(self):
if not self.config["enable_system_tray"]:
Modified: trunk/deluge/ui/web/json_api.py
===================================================================
--- trunk/deluge/ui/web/json_api.py 2009-12-25 21:27:07 UTC (rev 6061)
+++ trunk/deluge/ui/web/json_api.py 2009-12-25 21:29:47 UTC (rev 6062)
@@ -474,21 +474,17 @@
def got_connections(connections):
ui_info["stats"]["num_connections"] = connections
- def got_dht_nodes(nodes):
- ui_info["stats"]["dht_nodes"] = nodes
-
def got_stats(stats):
ui_info["stats"]["upload_rate"] = stats["payload_upload_rate"]
ui_info["stats"]["download_rate"] = stats["payload_download_rate"]
ui_info["stats"]["download_protocol_rate"] =
stats["download_rate"] - stats["payload_download_rate"]
ui_info["stats"]["upload_protocol_rate"] = stats["upload_rate"] -
stats["payload_upload_rate"]
+ ui_info["stats"]["dht_nodes"] = stats["dht_nodes"]
+ ui_info["stats"]["has_incoming_connections"] =
stats["has_incoming_connections"]
def got_filters(filters):
ui_info["filters"] = filters
- def got_health(health):
- ui_info["stats"]["has_incoming_connections"] = health
-
def got_free_space(free_space):
ui_info["stats"]["free_space"] = free_space
@@ -508,23 +504,19 @@
"payload_download_rate",
"payload_upload_rate",
"download_rate",
- "upload_rate"
+ "upload_rate",
+ "dht_nodes",
+ "has_incoming_connections"
])
d3.addCallback(got_stats)
d4 = client.core.get_num_connections()
d4.addCallback(got_connections)
- d5 = client.core.get_dht_nodes()
- d5.addCallback(got_dht_nodes)
+ d5 =
client.core.get_free_space(self.core_config.get("download_location"))
+ d5.addCallback(got_free_space)
- d6 = client.core.get_health()
- d6.addCallback(got_health)
-
- d7 =
client.core.get_free_space(self.core_config.get("download_location"))
- d7.addCallback(got_free_space)
-
- dl = DeferredList([d1, d2, d3, d4, d5, d6, d7], consumeErrors=True)
+ dl = DeferredList([d1, d2, d3, d4, d5], consumeErrors=True)
dl.addCallback(on_complete)
return d
--
You received this message because you are subscribed to the Google Groups
"deluge-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/deluge-commit?hl=en.