chiark / gitweb /
Some fixes to start support for python3.
authorDaid <daid303@gmail.com>
Thu, 21 Jun 2012 17:53:18 +0000 (19:53 +0200)
committerDaid <daid303@gmail.com>
Thu, 21 Jun 2012 17:53:18 +0000 (19:53 +0200)
15 files changed:
Cura/avr_isp/intelHex.py
Cura/avr_isp/ispBase.py
Cura/avr_isp/stk500v2.py
Cura/cura_sf/fabmetheus_utilities/archive.py
Cura/cura_sf/fabmetheus_utilities/euclidean.py
Cura/cura_sf/fabmetheus_utilities/gcodec.py
Cura/cura_sf/fabmetheus_utilities/settings.py
Cura/cura_sf/fabmetheus_utilities/xml_simple_writer.py
Cura/gui/sliceProgessPanel.py
Cura/util/profile.py
Cura/util/sliceRun.py
Cura/util/stl.py
Cura/util/svg.py
Cura/util/util3d.py
Cura/util/version.py

index 95c77a440e20eb138951ea7262fc69d12c05723c..2023873eded56c996839ceb1a97485710ae251f1 100644 (file)
@@ -30,6 +30,6 @@ def readHex(filename):
                elif recType == 2:      #Extended Segment Address Record\r
                        extraAddr = int(line[9:13], 16) * 16\r
                else:\r
-                       print recType, recLen, addr, checkSum, line\r
+                       print(recType, recLen, addr, checkSum, line)\r
        f.close()\r
        return data
\ No newline at end of file
index 2e61334b009678be2d3acbb733bbda1daf3a9513..5330d53e5205891bfc50a1535b27e0d62a735578 100644 (file)
@@ -12,9 +12,9 @@ class IspBase():
                        raise IspError("Chip with signature: " + str(self.getSignature()) + "not found")\r
                self.chipErase()\r
                \r
-               print "Flashing %i bytes" % len(flashData)\r
+               print("Flashing %i bytes" % len(flashData))\r
                self.writeFlash(flashData)\r
-               print "Verifying %i bytes" % len(flashData)\r
+               print("Verifying %i bytes" % len(flashData))\r
                self.verifyFlash(flashData)\r
 \r
        #low level ISP commands\r
index 58991b59c69e238be97d2d8b233da8b5a46cabf0..3945fb9d6646bd47d68b55b3ed5e9b032b7f6406 100644 (file)
@@ -101,7 +101,7 @@ class Stk500v2(ispBase.IspBase):
                                raise ispBase.IspError("Timeout")\r
                        b = struct.unpack(">B", s)[0]\r
                        checksum ^= b\r
-                       #print hex(b)\r
+                       #print(hex(b))\r
                        if state == 'Start':\r
                                if b == 0x1B:\r
                                        state = 'GetSeq'\r
index c9e56557ad2261740e6abe6fceac5eab1978f568..767dfd063e3987a354f62126714b679b7dc97b80 100644 (file)
@@ -115,7 +115,7 @@ def getFilePathsByDirectory(directoryName):
                        if os.path.dirname(name) == subpath:
                                filePaths.append(os.path.join(zipfilename, name))
                z.close()
-               print directoryName, filePaths
+               print(directoryName, filePaths)
        return filePaths
 
 def getFilePathsRecursively(fileInDirectory=''):
index f9c3148394a757243f90ff33c27ee17a325dae1a..898666c10f2b9d950843fa929f6601c7f9ed8d75 100644 (file)
@@ -32,10 +32,15 @@ import __init__
 
 from fabmetheus_utilities.vector3 import Vector3
 from fabmetheus_utilities import xml_simple_writer
-import cStringIO
+
+import sys
 import math
 import random
 
+if sys.version_info.major < 3:
+       import cStringIO
+else:
+       import io as cStringIO
 
 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
 __date__ = '$Date: 2008/21/04 $'
index b348674a99766865532ac9d7eb8dec9381feb3b0..1a6ac77b56aa435e0c10014e3e41a3c8190f791c 100644 (file)
@@ -23,12 +23,16 @@ import __init__
 from fabmetheus_utilities.vector3 import Vector3
 from fabmetheus_utilities import archive
 from fabmetheus_utilities import euclidean
-import cStringIO
+
 import math
 import os
 import sys
 import traceback
 
+if sys.version_info.major < 3:
+       import cStringIO
+else:
+       import io as cStringIO
 
 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
 __date__ = '$Date: 2008/21/04 $'
index 811aaeabcde15d9f90578adc6a520a1b7325c571..997f039a6fa0d3b5abf37435851d09bbf4c7242e 100644 (file)
@@ -415,7 +415,7 @@ def getReadRepository(repository):
        
        info = getProfileInformation()
        if not info.has_key(repository.name):
-               print "Warning: Plugin: " + repository.name + " missing from Cura info"
+               print("Warning: Plugin: " + repository.name + " missing from Cura info")
                return repository
        info = info[repository.name]
        
@@ -423,7 +423,7 @@ def getReadRepository(repository):
        for p in repository.preferences:
                name = safeConfigName(p.name)
                if not info.has_key(name):
-                       print "Setting: " + repository.name + ":" + name + " missing from Cura info"
+                       print("Setting: " + repository.name + ":" + name + " missing from Cura info")
                        continue
                if isinstance(info[name], types.FunctionType):
                        p.setValueToString(str(info[name](p)))
@@ -433,11 +433,11 @@ def getReadRepository(repository):
        return repository
 
 def printProgress(layerIndex, procedureName):
-       print ("Progress[" + procedureName + ":" + str(layerIndex+1) + "]")
+       print("Progress[" + procedureName + ":" + str(layerIndex+1) + "]")
        sys.stdout.flush()
 
 def printProgressByNumber(layerIndex, numberOfLayers, procedureName):
-       print ("Progress[" + procedureName + ":" + str(layerIndex+1) + ":" + str(numberOfLayers) + "]")
+       print("Progress[" + procedureName + ":" + str(layerIndex+1) + ":" + str(numberOfLayers) + "]")
        sys.stdout.flush()
 
 def getAlterationFileLines(fileName):
index 99e5ca6aabc358d81dce5671ae29ee1c2c9d3c6d..460ffca09340212e93951c1f4d203cce78515ed2 100644 (file)
@@ -8,7 +8,12 @@ from __future__ import absolute_import
 #Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
 import __init__
 
-import cStringIO
+import sys
+
+if sys.version_info.major < 3:
+       import cStringIO
+else:
+       import io as cStringIO
 
 
 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
index 344ea64280bb495e2cff69a50a003ff335ee853b..8a6a518992149f63e401369f339d16a725346b57 100644 (file)
@@ -40,7 +40,7 @@ class sliceProgessPanel(wx.Panel):
                cmdList = []
                for filename in self.filelist:
                        idx = self.filelist.index(filename)
-                       print filename, idx
+                       #print filename, idx
                        if idx > 0:
                                profile.setTempOverride('fan_enabled', 'False')
                                profile.setTempOverride('skirt_line_count', '0')
index fdc7135ae5729bd0c384e63ffa9e13c52056c379..6c06afb499dbc31423714b50a0c6bfef84309cc0 100644 (file)
@@ -3,7 +3,11 @@ from __future__ import division
 #Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.\r
 import __init__\r
 \r
-import ConfigParser, os, traceback, math, re, zlib, base64, time, sys\r
+import os, traceback, math, re, zlib, base64, time, sys\r
+if sys.version_info.major < 3:\r
+       import ConfigParser\r
+else:\r
+       import configparser as ConfigParser\r
 \r
 #########################################################\r
 ## Default settings when none are found.\r
@@ -247,13 +251,13 @@ def getProfileSetting(name):
                if name in profileDefaultSettings:\r
                        default = profileDefaultSettings[name]\r
                else:\r
-                       print "Missing default setting for: '" + name + "'"\r
+                       print("Missing default setting for: '" + name + "'")\r
                        profileDefaultSettings[name] = ''\r
                        default = ''\r
                if not globalProfileParser.has_section('profile'):\r
                        globalProfileParser.add_section('profile')\r
                globalProfileParser.set('profile', name, str(default))\r
-               #print name + " not found in profile, so using default: " + str(default)\r
+               #print(name + " not found in profile, so using default: " + str(default))\r
                return default\r
        return globalProfileParser.get('profile', name)\r
 \r
@@ -304,13 +308,13 @@ def getPreference(name):
                if name in preferencesDefaultSettings:\r
                        default = preferencesDefaultSettings[name]\r
                else:\r
-                       print "Missing default setting for: '" + name + "'"\r
+                       print("Missing default setting for: '" + name + "'")\r
                        preferencesDefaultSettings[name] = ''\r
                        default = ''\r
                if not globalPreferenceParser.has_section('preference'):\r
                        globalPreferenceParser.add_section('preference')\r
                globalPreferenceParser.set('preference', name, str(default))\r
-               #print name + " not found in preferences, so using default: " + str(default)\r
+               #print(name + " not found in preferences, so using default: " + str(default))\r
                return default\r
        return unicode(globalPreferenceParser.get('preference', name), "utf-8")\r
 \r
@@ -406,12 +410,12 @@ def getAlterationFile(filename):
                if filename in alterationDefault:\r
                        default = alterationDefault[filename]\r
                else:\r
-                       print "Missing default alteration for: '" + filename + "'"\r
+                       print("Missing default alteration for: '" + filename + "'")\r
                        alterationDefault[filename] = ''\r
                        default = ''\r
                if not globalProfileParser.has_section('alterations'):\r
                        globalProfileParser.add_section('alterations')\r
-               #print "Using default for: %s" % (filename)\r
+               #print("Using default for: %s" % (filename))\r
                globalProfileParser.set('alterations', filename, default)\r
        return unicode(globalProfileParser.get('alterations', filename), "utf-8")\r
 \r
index 483dbc5aa83290bb0538b5e97c63035d2b7a3df9..9941b9cc140a9b79f28687d3fc41378da9800756 100644 (file)
@@ -30,7 +30,7 @@ sliceStepTimeFactor = {
 }
 
 totalRunTimeFactor = 0
-for v in sliceStepTimeFactor.itervalues():
+for v in sliceStepTimeFactor.values():
        totalRunTimeFactor += v
 
 def getPyPyExe():
@@ -79,18 +79,18 @@ def runSlice(fileNames):
                        skeinforge_craft.writeOutput(fileName)
                elif pypyExe == False:
                        if not hasattr(sys, 'frozen'):
-                               print "************************************************"
-                               print "* Failed to find pypy, so slicing with python! *"
-                               print "************************************************"
+                               print("************************************************")
+                               print("* Failed to find pypy, so slicing with python! *")
+                               print("************************************************")
                                skeinforge_craft.writeOutput(fileName)
-                               print "************************************************"
-                               print "* Failed to find pypy, so sliced with python!  *"
-                               print "************************************************"
+                               print("************************************************")
+                               print("* Failed to find pypy, so sliced with python!  *")
+                               print("************************************************")
                        else:
-                               print "******************************************************************"
-                               print "* Failed to find pypy, we need pypy to slice with a frozen build *"
-                               print "* Place pypy in the same directory as Cura so Cura can find it.  *"
-                               print "******************************************************************"
+                               print("******************************************************************")
+                               print("* Failed to find pypy, we need pypy to slice with a frozen build *")
+                               print("* Place pypy in the same directory as Cura so Cura can find it.  *")
+                               print("******************************************************************")
                                sys.exit(1)
                else:
                        subprocess.call(getSliceCommand(fileName))
@@ -161,6 +161,9 @@ def getSliceCommand(filename):
                else:
                        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()]
-               cmd.append(filename)
+               if platform.system() == "Windows":
+                       cmd.append(str(filename))
+               else:
+                       cmd.append(filename)
                return cmd
 
index 8b87a417d2bd01ae733775db7898535407163421..9642ff2e8ee43dc32226646195171ba02c1c1eae 100644 (file)
@@ -70,7 +70,7 @@ def saveAsSTL(mesh, filename):
 if __name__ == '__main__':
        for filename in sys.argv[1:]:
                m = stlModel().load(filename)
-               print "Loaded %d faces" % (len(m.faces))
+               print("Loaded %d faces" % (len(m.faces)))
                parts = m.splitToParts()
                for p in parts:
                        saveAsSTL(p, "export_%i.stl" % parts.index(p))
index 8cd394cfc2292c72a6b018c687e237f1ac484393..596d7bb6c4ed612c158e7fd9cb8c0093b8a48b7e 100644 (file)
@@ -92,7 +92,7 @@ def processPath(e):
                                        curPath = [p]
                                        paths.append(curPath)
                                i = 0
-                               print param
+                               print(param)
                                while i < len(param):
                                        endPoint = p + complex(param[i+5], -param[i+6])
                                        addArc(curPath, p, endPoint, param[i], param[i+1], param[i+2], param[i+3], param[i+4])
@@ -102,7 +102,7 @@ def processPath(e):
                        elif cmd == 'Z' or cmd == 'z':
                                curPath.append(curPath[0])
                        elif cmd != None:
-                               print cmd
+                               print(cmd)
                        cmd = c
                        param = []
        return paths
index 43146a7e638282294a719c40fe205e3393df2861..2592785b8f0e4e13acd4155403043fb9d60cbaf8 100644 (file)
@@ -311,6 +311,6 @@ if __name__ == '__main__':
        tree.insert(AABB(Vector3(0,0,0), Vector3(0,0,0)))
        tree.insert(AABB(Vector3(1,1,1), Vector3(1,1,1)))
        tree.insert(AABB(Vector3(0.5,0.5,0.5), Vector3(0.5,0.5,0.5)))
-       print tree
-       print tree.query(AABB(Vector3(0,0,0), Vector3(0,0,0)))
+       print(tree)
+       print(tree.query(AABB(Vector3(0,0,0), Vector3(0,0,0))))
 
index 2c27a551366fe58e7e5e095bcdd9f7769502b881..624abf711538d94e4ca66b7f3a027af058314a9c 100644 (file)
@@ -16,5 +16,5 @@ def getVersion():
        return "?"
 
 if __name__ == '__main__':
-       print getVersion()
+       print(getVersion())