mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Also check for package updates automatically
Moves the 30-second sync timer from CloudOutputDeviceManager to Account and subscribes CloudPackageChecker to the timer. CURA-7290
This commit is contained in:
parent
637a241d99
commit
88ff68e40c
3 changed files with 37 additions and 29 deletions
|
@ -29,9 +29,6 @@ class CloudOutputDeviceManager:
|
|||
META_NETWORK_KEY = "um_network_key"
|
||||
SYNC_SERVICE_NAME = "CloudOutputDeviceManager"
|
||||
|
||||
# The interval with which the remote clusters are checked
|
||||
CHECK_CLUSTER_INTERVAL = 30.0 # seconds
|
||||
|
||||
# The translation catalog for this device.
|
||||
I18N_CATALOG = i18nCatalog("cura")
|
||||
|
||||
|
@ -45,13 +42,6 @@ class CloudOutputDeviceManager:
|
|||
self._api = CloudApiClient(self._account, on_error = lambda error: Logger.log("e", str(error)))
|
||||
self._account.loginStateChanged.connect(self._onLoginStateChanged)
|
||||
|
||||
# Create a timer to update the remote cluster list
|
||||
self._update_timer = QTimer()
|
||||
self._update_timer.setInterval(int(self.CHECK_CLUSTER_INTERVAL * 1000))
|
||||
# The timer is restarted explicitly after an update was processed. This prevents 2 concurrent updates
|
||||
self._update_timer.setSingleShot(True)
|
||||
self._update_timer.timeout.connect(self._getRemoteClusters)
|
||||
|
||||
# Ensure we don't start twice.
|
||||
self._running = False
|
||||
|
||||
|
@ -65,11 +55,9 @@ class CloudOutputDeviceManager:
|
|||
if not self._account.isLoggedIn:
|
||||
return
|
||||
self._running = True
|
||||
if not self._update_timer.isActive():
|
||||
self._update_timer.start()
|
||||
self._getRemoteClusters()
|
||||
|
||||
self._account.manualSyncRequested.connect(self._getRemoteClusters)
|
||||
self._account.syncRequested.connect(self._getRemoteClusters)
|
||||
|
||||
def stop(self):
|
||||
"""Stops running the cloud output device manager."""
|
||||
|
@ -77,8 +65,6 @@ class CloudOutputDeviceManager:
|
|||
if not self._running:
|
||||
return
|
||||
self._running = False
|
||||
if self._update_timer.isActive():
|
||||
self._update_timer.stop()
|
||||
self._onGetRemoteClustersFinished([]) # Make sure we remove all cloud output devices.
|
||||
|
||||
def refreshConnections(self) -> None:
|
||||
|
@ -100,8 +86,7 @@ class CloudOutputDeviceManager:
|
|||
if self._syncing:
|
||||
return
|
||||
|
||||
if self._update_timer.isActive():
|
||||
self._update_timer.stop()
|
||||
Logger.info("Syncing cloud printer clusters")
|
||||
|
||||
self._syncing = True
|
||||
self._account.setSyncState(self.SYNC_SERVICE_NAME, "syncing")
|
||||
|
@ -135,14 +120,10 @@ class CloudOutputDeviceManager:
|
|||
|
||||
self._syncing = False
|
||||
self._account.setSyncState(self.SYNC_SERVICE_NAME, "success")
|
||||
# Schedule a new update
|
||||
self._update_timer.start()
|
||||
|
||||
def _onGetRemoteClusterFailed(self):
|
||||
self._syncing = False
|
||||
self._account.setSyncState(self.SYNC_SERVICE_NAME, "error")
|
||||
# Schedule a new update
|
||||
self._update_timer.start()
|
||||
|
||||
def _onDevicesDiscovered(self, clusters: List[CloudClusterResponse]) -> None:
|
||||
"""**Synchronously** create machines for discovered devices
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue