diff --git a/plugins/UM3NetworkPrinting/src/Cloud/AbstractCloudOutputDevice.py b/plugins/UM3NetworkPrinting/src/Cloud/AbstractCloudOutputDevice.py index 566eae2ed9..bfda093d2e 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/AbstractCloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/AbstractCloudOutputDevice.py @@ -10,6 +10,7 @@ from cura.PrinterOutput.NetworkedPrinterOutputDevice import AuthState from cura.PrinterOutput.PrinterOutputDevice import ConnectionType from .CloudApiClient import CloudApiClient from ..Models.Http.CloudClusterResponse import CloudClusterResponse +from ..Models.Http.CloudClusterWithConfigResponse import CloudClusterWithConfigResponse from ..UltimakerNetworkedPrinterOutputDevice import UltimakerNetworkedPrinterOutputDevice I18N_CATALOG = i18nCatalog("cura") @@ -36,7 +37,6 @@ class AbstractCloudOutputDevice(UltimakerNetworkedPrinterOutputDevice): parent=parent ) - print("CREATING ABSTRACT CLOUD OUTPUT DEVIIICEEEEEE") self._setInterfaceElements() def connect(self) -> None: @@ -79,9 +79,15 @@ class AbstractCloudOutputDevice(UltimakerNetworkedPrinterOutputDevice): self.setDescription(I18N_CATALOG.i18nc("@properties:tooltip", "Print via cloud")) self.setConnectionText(I18N_CATALOG.i18nc("@info:status", "Connected via cloud")) - def _onCompleted(self, clusters: List[CloudClusterResponse]) -> None: + def _onCompleted(self, clusters: List[CloudClusterWithConfigResponse]) -> None: self._responseReceived() - # Todo: actually handle the data that we get back! + + all_configurations = [] + for resp in clusters: + if resp.configuration is not None: + # Usually when the printer is offline, it doesn't have a configuration... + all_configurations.append(resp.configuration) + self._updatePrinters(all_configurations) def _onError(self, reply: QNetworkReply, error: QNetworkReply.NetworkError) -> None: pass diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudApiClient.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudApiClient.py index 89f9e9d449..fbeef51f55 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudApiClient.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudApiClient.py @@ -17,6 +17,7 @@ from cura.UltimakerCloud import UltimakerCloudConstants from cura.UltimakerCloud.UltimakerCloudScope import UltimakerCloudScope from .ToolPathUploader import ToolPathUploader from ..Models.BaseModel import BaseModel +from ..Models.Http.CloudClusterWithConfigResponse import CloudClusterWithConfigResponse from ..Models.Http.CloudClusterResponse import CloudClusterResponse from ..Models.Http.CloudClusterStatus import CloudClusterStatus from ..Models.Http.CloudError import CloudError @@ -76,7 +77,7 @@ class CloudApiClient: error_callback = failed, timeout = self.DEFAULT_REQUEST_TIMEOUT) - def getClustersByMachineType(self, machine_type, on_finished: Callable[[List[CloudClusterResponse]], Any], failed: Callable) -> None: + def getClustersByMachineType(self, machine_type, on_finished: Callable[[List[CloudClusterWithConfigResponse]], Any], failed: Callable) -> None: # HACK: There is something weird going on with the API, as it reports printer types in formats like # "ultimaker_s3", but wants "Ultimaker S3" when using the machine_variant filter query. So we need to do some # conversion! @@ -90,7 +91,7 @@ class CloudApiClient: url = f"{self.CLUSTER_API_ROOT}/clusters?machine_variant={machine_type}" self._http.get(url, scope=self._scope, - callback=self._parseCallback(on_finished, CloudClusterResponse, failed), + callback=self._parseCallback(on_finished, CloudClusterWithConfigResponse, failed), error_callback=failed, timeout=self.DEFAULT_REQUEST_TIMEOUT) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py index 846ef0a8ec..a905cc8791 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py @@ -403,7 +403,6 @@ class CloudOutputDeviceManager: remote_abstract_cluster_copy: List[CloudOutputDevice] = list(self._abstract_clusters.values()) for device in remote_abstract_cluster_copy: if device.printerType == active_machine.definition.getId(): - print("Found the device to activate", device) self._connectToAbstractOutputDevice(device, active_machine) else: output_device_manager.removeOutputDevice(device.key) diff --git a/plugins/UM3NetworkPrinting/src/Models/Http/CloudClusterWithConfigResponse.py b/plugins/UM3NetworkPrinting/src/Models/Http/CloudClusterWithConfigResponse.py new file mode 100644 index 0000000000..eb6389910c --- /dev/null +++ b/plugins/UM3NetworkPrinting/src/Models/Http/CloudClusterWithConfigResponse.py @@ -0,0 +1,14 @@ +# Copyright (c) 2019 Ultimaker B.V. +# Cura is released under the terms of the LGPLv3 or higher. +from typing import Optional, List + +from .CloudClusterResponse import CloudClusterResponse +from .ClusterPrinterStatus import ClusterPrinterStatus + + +class CloudClusterWithConfigResponse(CloudClusterResponse): + """Class representing a cloud connected cluster.""" + + def __init__(self, **kwargs) -> None: + self.configuration = self.parseModel(ClusterPrinterStatus, kwargs.get("host_printer")) + super().__init__(**kwargs)