Merge pull request #10989 from Ultimaker/CURA-8671_dont_send_materials_to_um2c

[CURA-8671] Don't send materials to printers that can't receive them
This commit is contained in:
Jaime van Kessel 2021-12-06 09:48:18 +01:00 committed by GitHub
commit a64aa6ef2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 60 additions and 10 deletions

View file

@ -49,7 +49,9 @@ _ignored_machine_network_metadata = {
"removal_warning",
"group_name",
"group_size",
"connection_type"
"connection_type",
"capabilities",
"octoprint_api_key",
} # type: Set[str]

View file

@ -154,7 +154,8 @@ class ThreeMFWorkspaceWriter(WorkspaceWriter):
"group_name",
"group_size",
"connection_type",
"octoprint_api_key"
"capabilities",
"octoprint_api_key",
}
serialized_data = container.serialize(ignored_metadata_keys = ignore_keys)

View file

@ -19,7 +19,7 @@ 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
from cura.UltimakerCloud.UltimakerCloudConstants import META_CAPABILITIES, META_UM_LINKED_TO_ACCOUNT
from .CloudApiClient import CloudApiClient
from .CloudOutputDevice import CloudOutputDevice
from ..Models.Http.CloudClusterResponse import CloudClusterResponse
@ -128,6 +128,8 @@ class CloudOutputDeviceManager:
# to the current account
if not parseBool(self._um_cloud_printers[device_id].getMetaDataEntry(META_UM_LINKED_TO_ACCOUNT, "true")):
self._um_cloud_printers[device_id].setMetaDataEntry(META_UM_LINKED_TO_ACCOUNT, True)
if not self._um_cloud_printers[device_id].getMetaDataEntry(META_CAPABILITIES, None):
self._um_cloud_printers[device_id].setMetaDataEntry(META_CAPABILITIES, ",".join(cluster_data.capabilities))
self._onDevicesDiscovered(new_clusters)
self._updateOnlinePrinters(all_clusters)

View file

@ -37,7 +37,7 @@ class CloudClusterResponse(BaseModel):
self.friendly_name = friendly_name
self.printer_type = printer_type
self.printer_count = printer_count
self.capabilities = capabilities
self.capabilities = capabilities if capabilities is not None else []
super().__init__(**kwargs)
# Validates the model, raising an exception if the model is invalid.
@ -45,3 +45,10 @@ class CloudClusterResponse(BaseModel):
super().validate()
if not self.cluster_id:
raise ValueError("cluster_id is required on CloudCluster")
def __repr__(self) -> str:
"""
Convenience function for printing when debugging.
:return: A human-readable representation of the data in this object.
"""
return str({k: v for k, v in self.__dict__.items() if k in {"cluster_id", "host_guid", "host_name", "status", "is_online", "host_version", "host_internal_ip", "friendly_name", "printer_type", "printer_count", "capabilities"}})