mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-24 15:13:56 -06:00
Use optional arg in serialize() to exclude network auth keys
CURA-4049
This commit is contained in:
parent
7f1dfcf433
commit
68989f2871
2 changed files with 10 additions and 11 deletions
|
@ -69,7 +69,7 @@ class ThreeMFWorkspaceWriter(WorkspaceWriter):
|
|||
# \param archive The archive to write to.
|
||||
@staticmethod
|
||||
def _writeContainerToArchive(container, archive):
|
||||
if type(container) == type(ContainerRegistry.getInstance().getEmptyInstanceContainer()):
|
||||
if isinstance(container, type(ContainerRegistry.getInstance().getEmptyInstanceContainer())):
|
||||
return # Empty file, do nothing.
|
||||
|
||||
file_suffix = ContainerRegistry.getMimeTypeForContainer(type(container)).preferredSuffix
|
||||
|
@ -87,14 +87,9 @@ class ThreeMFWorkspaceWriter(WorkspaceWriter):
|
|||
file_in_archive = zipfile.ZipInfo(file_name)
|
||||
# For some reason we have to set the compress type of each file as well (it doesn't keep the type of the entire archive)
|
||||
file_in_archive.compress_type = zipfile.ZIP_DEFLATED
|
||||
if type(container) == ContainerStack and (container.getMetaDataEntry("network_authentication_id") or container.getMetaDataEntry("network_authentication_key")):
|
||||
# TODO: Hack
|
||||
# Create a shallow copy of the container, so we can filter out the network auth (if any)
|
||||
container_copy = copy.deepcopy(container)
|
||||
container_copy.removeMetaDataEntry("network_authentication_id")
|
||||
container_copy.removeMetaDataEntry("network_authentication_key")
|
||||
serialized_data = container_copy.serialize()
|
||||
else:
|
||||
serialized_data = container.serialize()
|
||||
|
||||
# Do not include the network authentication keys
|
||||
ignore_keys = ["network_authentication_id", "network_authentication_key"]
|
||||
serialized_data = container.serialize(ignore_metadata_keys = ignore_keys)
|
||||
|
||||
archive.writestr(file_in_archive, serialized_data)
|
||||
|
|
|
@ -109,7 +109,7 @@ class XmlMaterialProfile(InstanceContainer):
|
|||
## Overridden from InstanceContainer
|
||||
# base file: common settings + supported machines
|
||||
# machine / variant combination: only changes for itself.
|
||||
def serialize(self):
|
||||
def serialize(self, ignore_metadata_keys=[]):
|
||||
registry = ContainerRegistry.getInstance()
|
||||
|
||||
base_file = self.getMetaDataEntry("base_file", "")
|
||||
|
@ -129,6 +129,10 @@ class XmlMaterialProfile(InstanceContainer):
|
|||
builder.start("metadata")
|
||||
|
||||
metadata = copy.deepcopy(self.getMetaData())
|
||||
# remove the keys that we want to ignore in the metadata
|
||||
for key in ignore_metadata_keys:
|
||||
if key in metadata:
|
||||
del metadata[key]
|
||||
properties = metadata.pop("properties", {})
|
||||
|
||||
# Metadata properties that should not be serialized.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue