From 117cf10a2c60fa4687044ef473303b184634660d Mon Sep 17 00:00:00 2001 From: Daniel Schiavini Date: Wed, 5 Dec 2018 16:26:20 +0100 Subject: [PATCH] STAR-322: Removing devices when logging off --- plugins/UM3NetworkPrinting/src/Cloud/CloudApiClient.py | 2 +- .../src/Cloud/CloudOutputDeviceManager.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudApiClient.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudApiClient.py index 3ede206d45..b4c8774140 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudApiClient.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudApiClient.py @@ -129,7 +129,7 @@ class CloudApiClient(NetworkClient): data = response["data"] result = [model(**c) for c in data] if isinstance(data, list) else model(**data) on_finished(result) - elif "error" in response: + elif "errors" in response: self._on_error([CloudErrorObject(**error) for error in response["errors"]]) else: Logger.log("e", "Cannot find data or errors in the cloud response: %s", response) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py index f11d41a7bd..29514870ac 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py @@ -62,6 +62,10 @@ class CloudOutputDeviceManager: # The first call to _getRemoteClusters comes from self._account.loginStateChanged if not self._update_timer.isActive(): self._update_timer.start() + else: + self._onGetRemoteClustersFinished([]) + if self._update_timer.isActive(): + self._update_timer.stop() ## Callback for when the request for getting the clusters. is finished. def _onGetRemoteClustersFinished(self, clusters: List[CloudCluster]) -> None: @@ -73,6 +77,8 @@ class CloudOutputDeviceManager: # Remove output devices that are gone for removed_cluster in removed_devices: + if removed_cluster.isConnected(): + removed_cluster.disconnect() self._output_device_manager.removeOutputDevice(removed_cluster.key) del self._remote_clusters[removed_cluster.key]