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