From 8b6159523adcb12a88dd345fc252e031c130a6ba Mon Sep 17 00:00:00 2001 From: Daid Date: Thu, 21 Jun 2012 20:08:16 +0200 Subject: [PATCH] Fixed #116 - Slicing with none-ascii characters under windows. It is an ugly hack, but it works. --- Cura/cura_sf/fabmetheus_utilities/svg_writer.py | 2 +- Cura/util/sliceRun.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Cura/cura_sf/fabmetheus_utilities/svg_writer.py b/Cura/cura_sf/fabmetheus_utilities/svg_writer.py index 15855d26..a744a0b6 100644 --- a/Cura/cura_sf/fabmetheus_utilities/svg_writer.py +++ b/Cura/cura_sf/fabmetheus_utilities/svg_writer.py @@ -198,7 +198,7 @@ class SVGWriter: self.setMetadataNoscriptElement('minZ', 'Z: ', self.cornerMinimum.z) self.textHeight = float( self.sliceDictionary['textHeight'] ) controlTop = len(loopLayers) * (self.margin + self.extent.y * self.unitScale + self.textHeight) + self.marginTop + self.textHeight - self.svgElement.getFirstChildByLocalName('title').setTextContent(os.path.basename(fileName) + ' - Slice Layers') + self.svgElement.getFirstChildByLocalName('title').setTextContent(os.path.basename(fileName).encode("utf-8") + ' - Slice Layers') svgElementDictionary['height'] = '%spx' % self.getRounded(max(controlTop, self.controlBoxHeightMargin)) width = max(self.extent.x * self.unitScale, svgMinWidth) svgElementDictionary['width'] = '%spx' % self.getRounded( width ) diff --git a/Cura/util/sliceRun.py b/Cura/util/sliceRun.py index 9941b9cc..44b0a995 100644 --- a/Cura/util/sliceRun.py +++ b/Cura/util/sliceRun.py @@ -75,6 +75,8 @@ def runSlice(fileNames): "Run the slicer on the files. If we are running with PyPy then just do the slicing action. If we are running as Python, try to find pypy." pypyExe = getPyPyExe() for fileName in fileNames: + if fileName.startswith("#UTF8#"): + fileName = unicode(fileName[6:], "utf-8") if platform.python_implementation() == "PyPy": skeinforge_craft.writeOutput(fileName) elif pypyExe == False: @@ -162,7 +164,10 @@ def getSliceCommand(filename): mainScriptFile = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", os.path.split(sys.argv[0])[1])) cmd = [pypyExe, mainScriptFile, '-p', profile.getGlobalProfileString()] if platform.system() == "Windows": - cmd.append(str(filename)) + try: + cmd.append(str(filename)) + except UnicodeEncodeError: + cmd.append("#UTF8#" + filename.encode("utf-8")) else: cmd.append(filename) return cmd -- 2.30.2