Refactor the connection status to be informed by the autosync

The autosync, which happens every 30 seconds, will now also inform the
connection status when the get request succeeds or fails, which is an
indicator of whether the internet is reachable.

CURA-7492
This commit is contained in:
Kostas Karmas 2020-06-15 09:34:56 +02:00
parent e5a7ad2eca
commit ddf312eca5
2 changed files with 17 additions and 40 deletions

View file

@ -104,8 +104,10 @@ class CloudOutputDeviceManager:
self._api.getClusters(self._onGetRemoteClustersFinished, self._onGetRemoteClusterFailed)
def _onGetRemoteClustersFinished(self, clusters: List[CloudClusterResponse]) -> None:
"""Callback for when the request for getting the clusters is finished."""
"""Callback for when the request for getting the clusters is successful and finished."""
# Remote clusters were successfully retrieved, which means that the computer is online
CuraApplication.getInstance().getCuraAPI().connectionStatus.setOnlineStatus(True)
self._um_cloud_printers = {m.getMetaDataEntry(self.META_CLUSTER_ID): m for m in
CuraApplication.getInstance().getContainerRegistry().findContainerStacks(
type = "machine") if m.getMetaDataEntry(self.META_CLUSTER_ID, None)}
@ -150,6 +152,9 @@ class CloudOutputDeviceManager:
def _onGetRemoteClusterFailed(self, reply: QNetworkReply, error: QNetworkReply.NetworkError) -> None:
self._syncing = False
self._account.setSyncState(self.SYNC_SERVICE_NAME, SyncState.ERROR)
# If getting the remote clusters fails, then the cloud printers are unreachable, so we need to inform the
# connection status
CuraApplication.getInstance().getCuraAPI().connectionStatus.setOnlineStatus(False)
def _onDevicesDiscovered(self, clusters: List[CloudClusterResponse]) -> None:
"""**Synchronously** create machines for discovered devices