Cura/plugins/UM3NetworkPrinting/src/ExportFileJob.py
c.lamboo e66a3cda67 Only extend file formats for um3
This was a mistake in the previous implementation. The relevant piece of code was adding ufp support for um3 printers. This is legacy support for this printer since the printer didn't know it supported ufp, but through the digital factory it could support ufp files. However, with the addition of method printers we should have added an additional check where we also check if the printer is an um3. Instead an additional check was added that did the same for makerbot printers. Because of this check didn't have a "is method" check support for makerbot format is also added to s-line printers and legacy um printers.

(fyi @saumyaj3)

CURA-11377
2023-11-24 15:40:11 +01:00

46 lines
1.8 KiB
Python

# Copyright (c) 2021 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
import re # Filtering out invalid characters.
from typing import List, Optional
from UM.FileHandler.FileHandler import FileHandler
from UM.FileHandler.WriteFileJob import WriteFileJob
from UM.Logger import Logger
from UM.Scene.SceneNode import SceneNode
from cura.CuraApplication import CuraApplication
from .MeshFormatHandler import MeshFormatHandler
class ExportFileJob(WriteFileJob):
"""Job that exports the build plate to the correct file format for the target cluster."""
def __init__(self, file_handler: Optional[FileHandler], nodes: List[SceneNode], firmware_version: str,
print_type: str) -> None:
self._mesh_format_handler = MeshFormatHandler(file_handler, firmware_version, print_type)
if not self._mesh_format_handler.is_valid:
Logger.log("e", "Missing file or mesh writer!")
return
super().__init__(self._mesh_format_handler.writer, self._mesh_format_handler.createStream(), nodes,
self._mesh_format_handler.file_mode)
# Determine the filename.
job_name = CuraApplication.getInstance().getPrintInformation().jobName
job_name = re.sub("[^\w\-. ()]", "-", job_name)
extension = self._mesh_format_handler.preferred_format.get("extension", "")
self.setFileName("{}.{}".format(job_name, extension))
def getMimeType(self) -> str:
"""Get the mime type of the selected export file type."""
return self._mesh_format_handler.mime_type
def getOutput(self) -> bytes:
"""Get the job result as bytes as that is what we need to upload to the cluster."""
output = self.getStream().getvalue()
if isinstance(output, str):
output = output.encode("utf-8")
return output