diff --git a/ChangeLog b/ChangeLog index adf9f929f..4f16cd8c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,8 +2,7 @@ ==== Core ==== * Implement #1063 option to delete torrent file copy on torrent removal - patch from Ghent * Implement #457 progress bars for folders - -==== GtkUI ==== + * #496: Remove deprecated functions in favour of get_session_status() === Deluge 1.2.0 (In Development) === ==== Core ==== diff --git a/deluge/core/core.py b/deluge/core/core.py index bd767f14e..b0fbdce62 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -288,28 +288,6 @@ class Core(component.Component): log.debug("Removing torrent %s from the core.", torrent_id) 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): """ @@ -490,24 +468,6 @@ class Core(component.Component): """Returns the current number of connections""" 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""" @@ -605,12 +565,6 @@ class Core(component.Component): """Sets the path for the torrent to be moved when completed""" 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 diff --git a/deluge/ui/console/statusbars.py b/deluge/ui/console/statusbars.py index f9004c604..c7c6061ea 100644 --- a/deluge/ui/console/statusbars.py +++ b/deluge/ui/console/statusbars.py @@ -64,11 +64,6 @@ class StatusBars(component.Component): 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,11 +71,19 @@ class StatusBars(component.Component): 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): diff --git a/deluge/ui/gtkui/statusbar.py b/deluge/ui/gtkui/statusbar.py index e8da9daa4..41c001676 100644 --- a/deluge/ui/gtkui/statusbar.py +++ b/deluge/ui/gtkui/statusbar.py @@ -195,7 +195,6 @@ class StatusBar(component.Component): 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,17 +265,19 @@ class StatusBar(component.Component): 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): """ @@ -295,16 +296,12 @@ class StatusBar(component.Component): 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 @@ class StatusBar(component.Component): 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 @@ class StatusBar(component.Component): 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: diff --git a/deluge/ui/gtkui/systemtray.py b/deluge/ui/gtkui/systemtray.py index ae0ac607d..c2b44e333 100644 --- a/deluge/ui/gtkui/systemtray.py +++ b/deluge/ui/gtkui/systemtray.py @@ -169,8 +169,9 @@ class SystemTray(component.Component): 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 @@ class SystemTray(component.Component): 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"]: diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py index 5b9c54e78..343f81cd8 100644 --- a/deluge/ui/web/json_api.py +++ b/deluge/ui/web/json_api.py @@ -474,21 +474,17 @@ class WebApi(JSONComponent): 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 @@ class WebApi(JSONComponent): "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