mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Update online status when updating account printer status
This updates the metadata entries. Naturally this updates every 60 seconds in Cura, but it could also manually be triggered by the refresh button. Contributes to issue CURA-8609.
This commit is contained in:
parent
0bf4a3d944
commit
93953630ec
1 changed files with 14 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2020 Ultimaker B.V.
|
||||
# Copyright (c) 2021 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import os
|
||||
|
@ -16,6 +16,7 @@ from UM.Util import parseBool
|
|||
from cura.API import Account
|
||||
from cura.API.Account import SyncState
|
||||
from cura.CuraApplication import CuraApplication
|
||||
from cura.Settings.CuraContainerRegistry import CuraContainerRegistry # To update printer metadata with information received about cloud printers.
|
||||
from cura.Settings.CuraStackBuilder import CuraStackBuilder
|
||||
from cura.Settings.GlobalStack import GlobalStack
|
||||
from cura.UltimakerCloud.UltimakerCloudConstants import META_UM_LINKED_TO_ACCOUNT
|
||||
|
@ -129,6 +130,8 @@ class CloudOutputDeviceManager:
|
|||
self._um_cloud_printers[device_id].setMetaDataEntry(META_UM_LINKED_TO_ACCOUNT, True)
|
||||
self._onDevicesDiscovered(new_clusters)
|
||||
|
||||
self._updateOnlinePrinters(all_clusters)
|
||||
|
||||
# Hide the current removed_printers_message, if there is any
|
||||
if self._removed_printers_message:
|
||||
self._removed_printers_message.actionTriggered.disconnect(self._onRemovedPrintersMessageActionTriggered)
|
||||
|
@ -255,6 +258,16 @@ class CloudOutputDeviceManager:
|
|||
message_text = self.i18n_catalog.i18nc("info:status", "Printers added from Digital Factory:") + "<ul>" + device_names + "</ul>"
|
||||
message.setText(message_text)
|
||||
|
||||
def _updateOnlinePrinters(self, printer_responses: Dict[str, CloudClusterResponse]) -> None:
|
||||
"""
|
||||
Update the metadata of the printers to store whether they are online or not.
|
||||
:param printer_responses: The responses received from the API about the printer statuses.
|
||||
"""
|
||||
for container_stack in CuraContainerRegistry.getInstance().findContainerStacks(type = "machine"):
|
||||
cluster_id = container_stack.getMetaDataEntry("um_cloud_cluster_id", "")
|
||||
if cluster_id in printer_responses:
|
||||
container_stack.setMetaDataEntry("is_online", printer_responses[cluster_id].is_online)
|
||||
|
||||
def _updateOutdatedMachine(self, outdated_machine: GlobalStack, new_cloud_output_device: CloudOutputDevice) -> None:
|
||||
"""
|
||||
Update the cloud metadata of a pre-existing machine that is rediscovered (e.g. if the printer was removed and
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue