def checkNumbering(self):
"""Verify the internal order of the cards"""
err = 0
indent = 0
for i, card in enumerate(self.cardlist):
if card._pos != i:
err += 1
say("ERROR: Cards out of order pos=#%d it should be #%d" % (card.pos() + 1, i))
say(str(card))
if card.enable and card.tag in _INDENT_DEC:
indent = max(0, indent - 1)
if card.enable and card.indent() != indent:
say("ERROR: Indent out of order pos=#%d card._indent=%d it should be %d" % (i, card._indent, indent))
say(str(card))
if card.enable and card.tag in _INDENT_INC:
indent += 1
if err > 0:
say("ERROR: %d cards found out of order. Correcting error" % (err))
say("*** Please contact %s ***" % (__email__))
import traceback
traceback.print_stack()
self.renumber()
python类print_stack()的实例源码
def autostart(reason, *args, **kwargs):
if reason == 0:
if hasattr(PluginComponent, 'pluginHider_baseGetPlugins'):
print("[PluginHider] Something went wrong as our autostart handler was called multiple times for startup, printing traceback and ignoring.")
import traceback, sys
traceback.print_stack(limit=5, file=sys.stdout)
else:
PluginComponent.pluginHider_baseGetPlugins = PluginComponent.getPlugins
PluginComponent.getPlugins = PluginComponent_getPlugins
else:
if hasattr(PluginComponent, 'pluginHider_baseGetPlugins'):
PluginComponent.getPlugins = PluginComponent.pluginHider_baseGetPlugins
del PluginComponent.pluginHider_baseGetPlugins
else:
print("[PluginHider] Something went wrong as our autostart handler was called multiple times for shutdown, printing traceback and ignoring.")
import traceback, sys
traceback.print_stack(limit=5, file=sys.stdout)
def handleError(self, record):
print traceback.print_stack()
def write(self, x):
self.stdout.write(x)
traceback.print_stack()
def run(self):
while True:
with self.lock:
if self._stop is True:
return
print("\n============= THREAD FRAMES: ================")
for id, frame in sys._current_frames().items():
if id == threading.current_thread().ident:
continue
print("<< thread %d >>" % id)
traceback.print_stack(frame)
print("===============================================\n")
time.sleep(self.interval)
def __getattr__(self, attr):
"""Return the terminal with the given name"""
if attr not in self.terminals:
raise AttributeError(attr)
else:
import traceback
traceback.print_stack()
print("Warning: use of node.terminalName is deprecated; use node['terminalName'] instead.")
return self.terminals[attr]
def __getattr__(self, attr):
## Leaving this undocumented because I might like to remove it in the future..
#print type(self), attr
if 'names' not in self.__dict__:
raise AttributeError(attr)
if attr in self.names:
import traceback
traceback.print_stack()
print("Warning: Use of Parameter.subParam is deprecated. Use Parameter.param(name) instead.")
return self.param(attr)
else:
raise AttributeError(attr)
def write(self, x):
self.stdout.write(x)
traceback.print_stack()
def run(self):
while True:
with self.lock:
if self._stop is True:
return
print("\n============= THREAD FRAMES: ================")
for id, frame in sys._current_frames().items():
if id == threading.current_thread().ident:
continue
print("<< thread %d >>" % id)
traceback.print_stack(frame)
print("===============================================\n")
time.sleep(self.interval)
def __getattr__(self, attr):
"""Return the terminal with the given name"""
if attr not in self.terminals:
raise AttributeError(attr)
else:
import traceback
traceback.print_stack()
print("Warning: use of node.terminalName is deprecated; use node['terminalName'] instead.")
return self.terminals[attr]
def __getattr__(self, attr):
## Leaving this undocumented because I might like to remove it in the future..
#print type(self), attr
if 'names' not in self.__dict__:
raise AttributeError(attr)
if attr in self.names:
import traceback
traceback.print_stack()
print("Warning: Use of Parameter.subParam is deprecated. Use Parameter.param(name) instead.")
return self.param(attr)
else:
raise AttributeError(attr)
def assertException( exceptionType, f ):
"""Assert that an exception of type \var{exceptionType}
is thrown when the function \var{f} is evaluated.
"""
try: f()
except exceptionType: assert True
else:
print >>sys.stderr, "Error: expected <%s> to be thrown by function" % exceptionType.__name__
traceback.print_stack()
def assertFalse( b ):
"""assertFalse(b)
"""
if b:
print >>sys.stderr, "Error: expected value to be False"
traceback.print_stack()
def assertTrue( b ):
if not b:
print >>sys.stderr, "Error: expected value to be True"
traceback.print_stack()
####
# Test NamedSequences
####
def fake_conn_request(self):
# print a stacktrace to illustrate where the unmocked API call
# is being made from
traceback.print_stack()
# forcing a test failure for missing mock
self.missing_mocks = True
def _print_greenthreads():
for i, gt in enumerate(_find_objects(greenlet.greenlet)):
print(i, gt)
traceback.print_stack(gt.gr_frame)
print()
def _print_nativethreads():
for threadId, stack in sys._current_frames().items():
print(threadId)
traceback.print_stack(stack)
print()
def __call__(self, *args, **kw):
import traceback
log.msg('instance method %s.%s' % (reflect.qual(self.my_class), self.name))
log.msg('being called with %r %r' % (args, kw))
traceback.print_stack(file=log.logfile)
assert 0
def f():
traceback.print_stack(file=sys.stdout)
def traceback_3(self):
index = self.tb_preparation()
print('Traceback (most recent call last):')
traceback.print_stack(limit=-index)
sys.tracebacklimit = None
##############################################################################
# TypeError session.
##############################################################################
# ??????
# The argument(s) must be (a) number(s).