diff options
-rw-r--r-- | plugins/3MFWriter/ThreeMFWriter.py | 4 | ||||
-rw-r--r-- | plugins/GCodeGzWriter/GCodeGzWriter.py | 8 | ||||
-rw-r--r-- | plugins/GCodeWriter/GCodeWriter.py | 5 | ||||
-rw-r--r-- | plugins/UFPWriter/UFPWriter.py | 10 |
4 files changed, 25 insertions, 2 deletions
diff --git a/plugins/3MFWriter/ThreeMFWriter.py b/plugins/3MFWriter/ThreeMFWriter.py index 8d54f475d6..640aabd30c 100644 --- a/plugins/3MFWriter/ThreeMFWriter.py +++ b/plugins/3MFWriter/ThreeMFWriter.py @@ -25,6 +25,9 @@ except ImportError: import zipfile import UM.Application +from UM.i18n import i18nCatalog +catalog = i18nCatalog("cura") + class ThreeMFWriter(MeshWriter): def __init__(self): @@ -173,6 +176,7 @@ class ThreeMFWriter(MeshWriter): archive.writestr(relations_file, b'<?xml version="1.0" encoding="UTF-8"?> \n' + ET.tostring(relations_element)) except Exception as e: Logger.logException("e", "Error writing zip file") + self.setInformation(catalog.i18nc("@error:zip", "Error writing 3mf file.")) return False finally: if not self._store_archive: diff --git a/plugins/GCodeGzWriter/GCodeGzWriter.py b/plugins/GCodeGzWriter/GCodeGzWriter.py index 6ddecdb0bd..e191a9c427 100644 --- a/plugins/GCodeGzWriter/GCodeGzWriter.py +++ b/plugins/GCodeGzWriter/GCodeGzWriter.py @@ -10,6 +10,9 @@ from UM.Mesh.MeshWriter import MeshWriter #The class we're extending/implementin from UM.PluginRegistry import PluginRegistry from UM.Scene.SceneNode import SceneNode #For typing. +from UM.i18n import i18nCatalog +catalog = i18nCatalog("cura") + ## A file writer that writes gzipped g-code. # # If you're zipping g-code, you might as well use gzip! @@ -28,12 +31,15 @@ class GCodeGzWriter(MeshWriter): def write(self, stream: BufferedIOBase, nodes: List[SceneNode], mode = MeshWriter.OutputMode.BinaryMode) -> bool: if mode != MeshWriter.OutputMode.BinaryMode: Logger.log("e", "GCodeGzWriter does not support text mode.") + self.setInformation(catalog.i18nc("@error:not supported", "GCodeGzWriter does not support text mode.")) return False #Get the g-code from the g-code writer. gcode_textio = StringIO() #We have to convert the g-code into bytes. - success = cast(MeshWriter, PluginRegistry.getInstance().getPluginObject("GCodeWriter")).write(gcode_textio, None) + gcode_writer = cast(MeshWriter, PluginRegistry.getInstance().getPluginObject("GCodeWriter")) + success = gcode_writer.write(gcode_textio, None) if not success: #Writing the g-code failed. Then I can also not write the gzipped g-code. + self.setInformation(gcode_writer.getInformation()) return False result = gzip.compress(gcode_textio.getvalue().encode("utf-8")) diff --git a/plugins/GCodeWriter/GCodeWriter.py b/plugins/GCodeWriter/GCodeWriter.py index aea0698d19..59e9a29691 100644 --- a/plugins/GCodeWriter/GCodeWriter.py +++ b/plugins/GCodeWriter/GCodeWriter.py @@ -12,6 +12,8 @@ from UM.Settings.InstanceContainer import InstanceContainer from cura.Machines.QualityManager import getMachineDefinitionIDForQualitySearch +from UM.i18n import i18nCatalog +catalog = i18nCatalog("cura") ## Writes g-code to a file. # @@ -62,11 +64,13 @@ class GCodeWriter(MeshWriter): def write(self, stream, nodes, mode = MeshWriter.OutputMode.TextMode): if mode != MeshWriter.OutputMode.TextMode: Logger.log("e", "GCodeWriter does not support non-text mode.") + self.setInformation(catalog.i18nc("@error:not supported", "GCodeWriter does not support non-text mode.")) return False active_build_plate = Application.getInstance().getMultiBuildPlateModel().activeBuildPlate scene = Application.getInstance().getController().getScene() if not hasattr(scene, "gcode_dict"): + self.setInformation(catalog.i18nc("@warning:status", "Please generate G-code before saving.")) return False gcode_dict = getattr(scene, "gcode_dict") gcode_list = gcode_dict.get(active_build_plate, None) @@ -82,6 +86,7 @@ class GCodeWriter(MeshWriter): stream.write(settings) return True + self.setInformation(catalog.i18nc("@warning:status", "Please generate G-code before saving.")) return False ## Create a new container with container 2 as base and container 1 written over it. diff --git a/plugins/UFPWriter/UFPWriter.py b/plugins/UFPWriter/UFPWriter.py index aca293e25a..9344bf54da 100644 --- a/plugins/UFPWriter/UFPWriter.py +++ b/plugins/UFPWriter/UFPWriter.py @@ -1,5 +1,6 @@ #Copyright (c) 2018 Ultimaker B.V. #Cura is released under the terms of the LGPLv3 or higher. +from typing import cast from Charon.VirtualFile import VirtualFile #To open UFP files. from Charon.OpenMode import OpenMode #To indicate that we want to write to UFP files. @@ -13,6 +14,9 @@ from PyQt5.QtCore import QBuffer from cura.Snapshot import Snapshot +from UM.i18n import i18nCatalog +catalog = i18nCatalog("cura") + class UFPWriter(MeshWriter): def __init__(self): @@ -32,7 +36,11 @@ class UFPWriter(MeshWriter): #Store the g-code from the scene. archive.addContentType(extension = "gcode", mime_type = "text/x-gcode") gcode_textio = StringIO() #We have to convert the g-code into bytes. - PluginRegistry.getInstance().getPluginObject("GCodeWriter").write(gcode_textio, None) + gcode_writer = cast(MeshWriter, PluginRegistry.getInstance().getPluginObject("GCodeWriter")) + success = gcode_writer.write(gcode_textio, None) + if not success: #Writing the g-code failed. Then I can also not write the gzipped g-code. + self.setInformation(gcode_writer.getInformation()) + return False gcode = archive.getStream("/3D/model.gcode") gcode.write(gcode_textio.getvalue().encode("UTF-8")) archive.addRelation(virtual_path = "/3D/model.gcode", relation_type = "http://schemas.ultimaker.org/package/2018/relationships/gcode") |