mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
better exception wrapping for __dev__ builtin in report()
This commit is contained in:
parent
c5c375aadf
commit
804d0dde03
@ -2492,67 +2492,68 @@ class ClassTree:
|
|||||||
|
|
||||||
|
|
||||||
def report(types = [], notifyFunc = None, dConfigParam = []):
|
def report(types = [], notifyFunc = None, dConfigParam = []):
|
||||||
|
def decorator(f):
|
||||||
|
return f
|
||||||
try:
|
try:
|
||||||
def decorator(f):
|
if not __dev__:
|
||||||
__dev__
|
return decorator
|
||||||
def wrap(*args,**kwargs):
|
except NameError,e:
|
||||||
aargs = args
|
return decorator
|
||||||
kkwargs = kwargs
|
|
||||||
rArgs = [`x`+', ' for x in args] + [ x + ' = ' + '%s, ' % `y` for x,y in kwargs.items()]
|
|
||||||
|
|
||||||
if not rArgs:
|
def decorator(f):
|
||||||
rArgs = '()'
|
def wrap(*args,**kwargs):
|
||||||
else:
|
aargs = args
|
||||||
rArgs = '(' + reduce(str.__add__,rArgs)[:-2] + ')'
|
kkwargs = kwargs
|
||||||
|
rArgs = [`x`+', ' for x in args] + [ x + ' = ' + '%s, ' % `y` for x,y in kwargs.items()]
|
||||||
|
|
||||||
outStr = f.func_name + rArgs
|
if not rArgs:
|
||||||
|
rArgs = '()'
|
||||||
|
else:
|
||||||
|
rArgs = '(' + reduce(str.__add__,rArgs)[:-2] + ')'
|
||||||
|
|
||||||
if 'frameCount' in types:
|
outStr = f.func_name + rArgs
|
||||||
outStr = '%8d : %s' % (globalClock.getFrameCount(), outStr)
|
|
||||||
|
|
||||||
if 'timeStamp' in types:
|
if 'frameCount' in types:
|
||||||
outStr = '%5.3f : %s' % (globalClock.getFrameTime(), outStr)
|
outStr = '%8d : %s' % (globalClock.getFrameCount(), outStr)
|
||||||
|
|
||||||
if 'avLocation' in types:
|
if 'timeStamp' in types:
|
||||||
outStr = '%s : %s' % (outStr, str(localAvatar.getLocation()))
|
outStr = '%5.3f : %s' % (globalClock.getFrameTime(), outStr)
|
||||||
|
|
||||||
# determine whether we should print
|
if 'avLocation' in types:
|
||||||
doPrint = False
|
outStr = '%s : %s' % (outStr, str(localAvatar.getLocation()))
|
||||||
if not dConfigParam:
|
|
||||||
doPrint = True
|
# determine whether we should print
|
||||||
else:
|
doPrint = False
|
||||||
if isinstance(dConfigParam,str):
|
if not dConfigParam:
|
||||||
|
doPrint = True
|
||||||
|
else:
|
||||||
|
if isinstance(dConfigParam,str):
|
||||||
|
if(config.GetBool(dConfigParam, 0)):
|
||||||
|
doPrint = True
|
||||||
|
elif isinstance(dConfigParam, (list,tuple)):
|
||||||
|
for param in dConfigParam:
|
||||||
if(config.GetBool(dConfigParam, 0)):
|
if(config.GetBool(dConfigParam, 0)):
|
||||||
doPrint = True
|
doPrint = True
|
||||||
elif isinstance(dConfigParam, (list,tuple)):
|
break
|
||||||
for param in dConfigParam:
|
|
||||||
if(config.GetBool(dConfigParam, 0)):
|
|
||||||
doPrint = True
|
|
||||||
break
|
|
||||||
|
|
||||||
if doPrint:
|
if doPrint:
|
||||||
if notifyFunc:
|
if notifyFunc:
|
||||||
notifyFunc(outStr)
|
notifyFunc(outStr)
|
||||||
else:
|
else:
|
||||||
print outStr
|
print outStr
|
||||||
|
|
||||||
if 'printInterests' in types:
|
if 'printInterests' in types:
|
||||||
base.cr.printInterestSets()
|
base.cr.printInterestSets()
|
||||||
|
|
||||||
if 'stackTrace' in types:
|
if 'stackTrace' in types:
|
||||||
print StackTrace()
|
print StackTrace()
|
||||||
|
|
||||||
return f(*args,**kwargs)
|
return f(*args,**kwargs)
|
||||||
|
|
||||||
wrap.func_name = f.func_name
|
wrap.func_name = f.func_name
|
||||||
wrap.func_dict = f.func_dict
|
wrap.func_dict = f.func_dict
|
||||||
wrap.func_doc = f.func_doc
|
wrap.func_doc = f.func_doc
|
||||||
return wrap
|
return wrap
|
||||||
except NameError,e:
|
|
||||||
print e
|
|
||||||
print 'Error decorating %s in %s with @report' % (f.func_name, f.__module__)
|
|
||||||
def decorator(f):
|
|
||||||
return f
|
|
||||||
|
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user