mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 18:57:52 -06:00
Fix status interval check for cloud devices
This commit is contained in:
parent
00334ee5a9
commit
e6d30516aa
2 changed files with 6 additions and 5 deletions
|
@ -148,8 +148,9 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
||||||
## Called when the network data should be updated.
|
## Called when the network data should be updated.
|
||||||
def _update(self) -> None:
|
def _update(self) -> None:
|
||||||
super()._update()
|
super()._update()
|
||||||
if self._last_request_time and time() - self._last_request_time < self.CHECK_CLUSTER_INTERVAL:
|
if time() - self._time_of_last_request < self.CHECK_CLUSTER_INTERVAL:
|
||||||
return # Avoid calling the cloud too often
|
return # avoid calling the cloud too often
|
||||||
|
self._time_of_last_request = time()
|
||||||
if self._account.isLoggedIn:
|
if self._account.isLoggedIn:
|
||||||
self.setAuthenticationState(AuthState.Authenticated)
|
self.setAuthenticationState(AuthState.Authenticated)
|
||||||
self._last_request_time = time()
|
self._last_request_time = time()
|
||||||
|
@ -160,9 +161,8 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
||||||
## Method called when HTTP request to status endpoint is finished.
|
## Method called when HTTP request to status endpoint is finished.
|
||||||
# Contains both printers and print jobs statuses in a single response.
|
# Contains both printers and print jobs statuses in a single response.
|
||||||
def _onStatusCallFinished(self, status: CloudClusterStatus) -> None:
|
def _onStatusCallFinished(self, status: CloudClusterStatus) -> None:
|
||||||
# Update all data from the cluster.
|
self._responseReceived()
|
||||||
self._last_response_time = time()
|
if status.printers != self._received_printers:
|
||||||
if self._received_printers != status.printers:
|
|
||||||
self._received_printers = status.printers
|
self._received_printers = status.printers
|
||||||
self._updatePrinters(status.printers)
|
self._updatePrinters(status.printers)
|
||||||
if status.print_jobs != self._received_print_jobs:
|
if status.print_jobs != self._received_print_jobs:
|
||||||
|
|
|
@ -57,6 +57,7 @@ class UltimakerNetworkedPrinterOutputDevice(NetworkedPrinterOutputDevice):
|
||||||
|
|
||||||
# Keeps track the last network response to determine if we are still connected.
|
# Keeps track the last network response to determine if we are still connected.
|
||||||
self._time_of_last_response = time()
|
self._time_of_last_response = time()
|
||||||
|
self._time_of_last_request = time()
|
||||||
|
|
||||||
# Set the display name from the properties
|
# Set the display name from the properties
|
||||||
self.setName(self.getProperty("name"))
|
self.setName(self.getProperty("name"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue