def do_printstack(self, arg): if 'stack' in self.__dict__: # print only the stack up to our current depth frame = self.stack[-1][0] else: frame = sys._getframe(1) while frame.f_globals['__name__'] in ('epdb', 'pdb', 'bdb', 'cmd'): frame = frame.f_back stackutil.printStack(frame, sys.stderr)
def do_savestack(self, path): if 'stack' in self.__dict__: # when we're saving we always # start from the top frame = self.stack[-1][0] else: frame = sys._getframe(1) while frame.f_globals['__name__'] in ('epdb', 'pdb', 'bdb', 'cmd'): frame = frame.f_back if path == "": (tbfd,path) = tempfile.mkstemp('', 'conary-stack-') output = os.fdopen(tbfd, 'w') else: output = open(path, 'w') stackutil.printStack(frame, output) print "Stack saved to %s" % path