Fixed print statements for python 3

This commit is contained in:
Luke Campagnola 2013-01-12 14:35:32 -05:00
parent e234d90f02
commit 253d27d392
9 changed files with 32 additions and 32 deletions

View File

@ -393,7 +393,7 @@ class Profiler:
if self.delayed:
self.msgs.append(msg2)
else:
print msg2
print(msg2)
self.t0 = ptime.time()
self.t1 = self.t0
@ -410,7 +410,7 @@ class Profiler:
if self.delayed:
self.msgs.append(msg2)
else:
print msg2
print(msg2)
self.t1 = ptime.time() ## don't measure time it took to print
def finish(self, msg=None):
@ -425,10 +425,10 @@ class Profiler:
self.msgs.append(msg)
if self.depth == 0:
for line in self.msgs:
print line
print(line)
Profiler.msgs = []
else:
print msg
print(msg)
Profiler.depth = self.depth
self.finished = True

View File

@ -220,7 +220,7 @@ def _generateItemSvg(item, nodes=None, root=None):
## get list of sub-groups
g2 = [n for n in g1.childNodes if isinstance(n, xml.Element) and n.tagName == 'g']
except:
print doc.toxml()
print(doc.toxml())
raise

View File

@ -236,7 +236,7 @@ class EvalNode(Node):
text = fn + "\n".join([" "+l for l in str(self.text.toPlainText()).split('\n')]) + run
exec(text)
except:
print "Error processing node:", self.name()
print("Error processing node: %s" % self.name())
raise
return output

View File

@ -798,7 +798,7 @@ def makeARGB(data, lut=None, levels=None, scale=None, useRGBA=False):
if levels.shape != (data.shape[-1], 2):
raise Exception('levels must have shape (data.shape[-1], 2)')
else:
print levels
print(levels)
raise Exception("levels argument must be 1D or 2D.")
#levels = np.array(levels)
#if levels.shape == (2,):

View File

@ -19,7 +19,7 @@ class Parallelize(object):
for task in tasks:
result = processTask(task)
results.append(result)
print results
print(results)
## Here is the parallelized version:
@ -30,7 +30,7 @@ class Parallelize(object):
for task in tasker:
result = processTask(task)
tasker.results.append(result)
print results
print(results)
The only major caveat is that *result* in the example above must be picklable,

View File

@ -232,7 +232,7 @@ class ForkedProcess(RemoteEventHandler):
except ClosedError:
break
except:
print "Error occurred in forked event loop:"
print("Error occurred in forked event loop:")
sys.excepthook(*sys.exc_info())
sys.exit(0)
@ -297,7 +297,7 @@ class QtProcess(Process):
btn.show()
def slot():
print 'slot invoked on parent process'
print('slot invoked on parent process')
btn.clicked.connect(proxy(slot)) # be sure to send a proxy of the slot
"""

View File

@ -68,7 +68,7 @@ class RemoteEventHandler(object):
try:
return cls.handlers[pid]
except:
print pid, cls.handlers
print(pid, cls.handlers)
raise
def getProxyOption(self, opt):
@ -103,7 +103,7 @@ class RemoteEventHandler(object):
else:
raise
except:
print "Error in process %s" % self.name
print("Error in process %s" % self.name)
sys.excepthook(*sys.exc_info())
return numProcessed
@ -239,7 +239,7 @@ class RemoteEventHandler(object):
self.send(request='result', reqId=reqId, callSync='off', opts=dict(result=result))
def replyError(self, reqId, *exc):
print "error:", self.name, reqId, exc[1]
print("error: %s %s %s" % (self.name, str(reqId), str(exc[1])))
excStr = traceback.format_exception(*exc)
try:
self.send(request='error', reqId=reqId, callSync='off', opts=dict(exception=exc[1], excString=excStr))
@ -352,9 +352,9 @@ class RemoteEventHandler(object):
try:
optStr = pickle.dumps(opts)
except:
print "==== Error pickling this object: ===="
print opts
print "======================================="
print("==== Error pickling this object: ====")
print(opts)
print("=======================================")
raise
nByteMsgs = 0
@ -404,12 +404,12 @@ class RemoteEventHandler(object):
#print ''.join(result)
exc, excStr = result
if exc is not None:
print "===== Remote process raised exception on request: ====="
print ''.join(excStr)
print "===== Local Traceback to request follows: ====="
print("===== Remote process raised exception on request: =====")
print(''.join(excStr))
print("===== Local Traceback to request follows: =====")
raise exc
else:
print ''.join(excStr)
print(''.join(excStr))
raise Exception("Error getting result. See above for exception from remote process.")
else:
@ -535,7 +535,7 @@ class Request(object):
raise ClosedError()
time.sleep(0.005)
if timeout >= 0 and time.time() - start > timeout:
print "Request timed out:", self.description
print("Request timed out: %s" % self.description)
import traceback
traceback.print_stack()
raise NoResultError()

View File

@ -6,10 +6,10 @@ class GLTest(QtOpenGL.QGLWidget):
def __init__(self):
QtOpenGL.QGLWidget.__init__(self)
self.makeCurrent()
print "GL version:", glGetString(GL_VERSION)
print "MAX_TEXTURE_SIZE:", glGetIntegerv(GL_MAX_TEXTURE_SIZE)
print "MAX_3D_TEXTURE_SIZE:", glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE)
print "Extensions:", glGetString(GL_EXTENSIONS)
print("GL version:" + glGetString(GL_VERSION))
print("MAX_TEXTURE_SIZE: %d" % glGetIntegerv(GL_MAX_TEXTURE_SIZE))
print("MAX_3D_TEXTURE_SIZE: %d" % glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE))
print("Extensions: " + glGetString(GL_EXTENSIONS))
GLTest()

View File

@ -267,14 +267,14 @@ class A(object):
object.__init__(self)
self.msg = msg
def fn(self, pfx = ""):
print pfx+"A class:", self.__class__, id(self.__class__)
print pfx+" %%s: %d" %% self.msg
print(pfx+"A class: %%s %%s" %% (str(self.__class__), str(id(self.__class__))))
print(pfx+" %%s: %d" %% self.msg)
class B(A):
def fn(self, pfx=""):
print pfx+"B class:", self.__class__, id(self.__class__)
print pfx+" %%s: %d" %% self.msg
print pfx+" calling superclass.. (%%s)" %% id(A)
print(pfx+"B class:", self.__class__, id(self.__class__))
print(pfx+" %%s: %d" %% self.msg)
print(pfx+" calling superclass.. (%%s)" %% id(A) )
A.fn(self, " ")
"""
@ -294,7 +294,7 @@ class C(A):
A.__init__(self, msg + "(init from C)")
def fn():
print "fn: %s"
print("fn: %s")
"""
open(modFile1, 'w').write(modCode1%(1,1))