better exception wrapping for __dev__ builtin in report()

This commit is contained in:
Josh Wilson 2007-02-26 21:26:08 +00:00
parent c5c375aadf
commit 804d0dde03

View File

@ -2492,68 +2492,69 @@ 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()] 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: outStr = f.func_name + rArgs
rArgs = '()'
else: if 'frameCount' in types:
rArgs = '(' + reduce(str.__add__,rArgs)[:-2] + ')' outStr = '%8d : %s' % (globalClock.getFrameCount(), outStr)
if 'timeStamp' in types:
outStr = '%5.3f : %s' % (globalClock.getFrameTime(), outStr)
outStr = f.func_name + rArgs if 'avLocation' in types:
outStr = '%s : %s' % (outStr, str(localAvatar.getLocation()))
if 'frameCount' in types:
outStr = '%8d : %s' % (globalClock.getFrameCount(), outStr) # determine whether we should print
doPrint = False
if 'timeStamp' in types: if not dConfigParam:
outStr = '%5.3f : %s' % (globalClock.getFrameTime(), outStr) doPrint = True
else:
if 'avLocation' in types: if isinstance(dConfigParam,str):
outStr = '%s : %s' % (outStr, str(localAvatar.getLocation())) if(config.GetBool(dConfigParam, 0)):
doPrint = True
# determine whether we should print elif isinstance(dConfigParam, (list,tuple)):
doPrint = False for param in dConfigParam:
if not dConfigParam:
doPrint = True
else:
if isinstance(dConfigParam,str):
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
def getBase(): def getBase():