Ensure that all material configs are added to the list

CURA-8463
This commit is contained in:
Jaime van Kessel 2022-08-30 16:33:29 +02:00
parent 6fed6b824c
commit e2ba110cf7
No known key found for this signature in database
GPG Key ID: C85F7A3AF1BAA7C4
4 changed files with 26 additions and 6 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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)