Some fixes to start support for python3.

master
Daid 2012-06-21 19:53:18 +02:00
parent 906d0f9718
commit 1b56cd18d7
15 changed files with 59 additions and 38 deletions

View File

@ -30,6 +30,6 @@ def readHex(filename):
elif recType == 2: #Extended Segment Address Record
extraAddr = int(line[9:13], 16) * 16
else:
print recType, recLen, addr, checkSum, line
print(recType, recLen, addr, checkSum, line)
f.close()
return data

View File

@ -12,9 +12,9 @@ class IspBase():
raise IspError("Chip with signature: " + str(self.getSignature()) + "not found")
self.chipErase()
print "Flashing %i bytes" % len(flashData)
print("Flashing %i bytes" % len(flashData))
self.writeFlash(flashData)
print "Verifying %i bytes" % len(flashData)
print("Verifying %i bytes" % len(flashData))
self.verifyFlash(flashData)
#low level ISP commands

View File

@ -101,7 +101,7 @@ class Stk500v2(ispBase.IspBase):
raise ispBase.IspError("Timeout")
b = struct.unpack(">B", s)[0]
checksum ^= b
#print hex(b)
#print(hex(b))
if state == 'Start':
if b == 0x1B:
state = 'GetSeq'

View 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=''):

View 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 $'

View 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 $'

View 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):

View 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)'

View 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')

View 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.
import __init__
import ConfigParser, os, traceback, math, re, zlib, base64, time, sys
import os, traceback, math, re, zlib, base64, time, sys
if sys.version_info.major < 3:
import ConfigParser
else:
import configparser as ConfigParser
#########################################################
## Default settings when none are found.
@ -247,13 +251,13 @@ def getProfileSetting(name):
if name in profileDefaultSettings:
default = profileDefaultSettings[name]
else:
print "Missing default setting for: '" + name + "'"
print("Missing default setting for: '" + name + "'")
profileDefaultSettings[name] = ''
default = ''
if not globalProfileParser.has_section('profile'):
globalProfileParser.add_section('profile')
globalProfileParser.set('profile', name, str(default))
#print name + " not found in profile, so using default: " + str(default)
#print(name + " not found in profile, so using default: " + str(default))
return default
return globalProfileParser.get('profile', name)
@ -304,13 +308,13 @@ def getPreference(name):
if name in preferencesDefaultSettings:
default = preferencesDefaultSettings[name]
else:
print "Missing default setting for: '" + name + "'"
print("Missing default setting for: '" + name + "'")
preferencesDefaultSettings[name] = ''
default = ''
if not globalPreferenceParser.has_section('preference'):
globalPreferenceParser.add_section('preference')
globalPreferenceParser.set('preference', name, str(default))
#print name + " not found in preferences, so using default: " + str(default)
#print(name + " not found in preferences, so using default: " + str(default))
return default
return unicode(globalPreferenceParser.get('preference', name), "utf-8")
@ -406,12 +410,12 @@ def getAlterationFile(filename):
if filename in alterationDefault:
default = alterationDefault[filename]
else:
print "Missing default alteration for: '" + filename + "'"
print("Missing default alteration for: '" + filename + "'")
alterationDefault[filename] = ''
default = ''
if not globalProfileParser.has_section('alterations'):
globalProfileParser.add_section('alterations')
#print "Using default for: %s" % (filename)
#print("Using default for: %s" % (filename))
globalProfileParser.set('alterations', filename, default)
return unicode(globalProfileParser.get('alterations', filename), "utf-8")

View 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

View 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))

View 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

View 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))))

View File

@ -16,5 +16,5 @@ def getVersion():
return "?"
if __name__ == '__main__':
print getVersion()
print(getVersion())