mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-01 00:04:27 +08:00
Ensure that all material configs are added to the list
CURA-8463
This commit is contained in:
parent
6fed6b824c
commit
e2ba110cf7
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
Loading…
x
Reference in New Issue
Block a user