chiark / gitweb /
Fixed #116 - Slicing with none-ascii characters under windows. It is an ugly hack...
authorDaid <daid303@gmail.com>
Thu, 21 Jun 2012 18:08:16 +0000 (20:08 +0200)
committerDaid <daid303@gmail.com>
Thu, 21 Jun 2012 18:08:16 +0000 (20:08 +0200)
Cura/cura_sf/fabmetheus_utilities/svg_writer.py
Cura/util/sliceRun.py

index 15855d2644d64fc98e34051fab83cb1400821970..a744a0b687c7809108cb1e3d4f5ae470df7dcef5 100644 (file)
@@ -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 )
index 9941b9cc140a9b79f28687d3fc41378da9800756..44b0a995516ba6dc9d15a987d5ca9b3de4db0484 100644 (file)
@@ -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