|
@@ -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"))
|