def timeit_stamp(frame=None, show_stats=False): """ Usage:: timeit_stamp(inspect.currentframe()) :param frame: :param show_stats: """ config = globals() GLOBAL_KEY = config['timeit_GLOBAL_KEY'] t = time.time() - config[GLOBAL_KEY]['timeit__start'] stats = config[GLOBAL_KEY]['timeit__stats'] callable_ = linecache.getline(__file__, inspect.getlineno(frame)) lineno = inspect.getlineno(frame) print '\t *** tracepoint at line: %s %.3f|%s' % (lineno, t, callable_.strip()) if (stats['total'] < t): stats['total'] = t stats['last_line'] = lineno if stats['first_line'] is None: stats['first_line'] = lineno config[GLOBAL_KEY]['timeit__start_int'] = time.time() if show_stats: print stats
def testPassesGoToFile(self): testlog.logSuccesses = True testlog.assertEqual(4, 4) answer = u'PASSED: testlogger_tests.py line '+str(inspect.getlineno(sys._getframe()) -1)+': testlog.assertEqual(4, 4)\n' self.assertEqual(self.log.getvalue()[28:], answer) testlog.assertEqual(4, 3) answer = u'FAILED: 4 != 3 in testlogger_tests.py line '+str(inspect.getlineno(sys._getframe()) -1)+ ': testlog.assertEqual(4, 3)\n' self.assertEqual(self.log.getvalue()[119:], answer)
def user_line(self, frame): """This function is called when we stop or break at this line. However it's *also* called when line OR function tracing is in effect. A little bit confusing and this code needs to be simplified.""" self.stop_reason = 'line' if self._wait_for_mainpyfile: if (self.mainpyfile != self.canonic_filename(frame) or inspect.getlineno(frame) <= 0): return self._wait_for_mainpyfile = False if self.stop_here(frame) or self.linetrace or self.fntrace: # Don't stop if we are looking at a def for which a breakpoint # has not been set. filename = frame2file(self, frame) # Python 2.5 or greater has 3 arg getline which handles # eggs and zip files if 3 == linecache.getline.func_code.co_argcount: line = linecache.getline(filename, inspect.getlineno(frame), frame.f_globals) else: line = linecache.getline(filename, inspect.getlineno(frame)) pass # No, we don't have a breakpoint. So we are either # stepping or here because of line tracing. if self.step_ignore > 0: # Don't stop this time, just note a step was done in # step count self.step_ignore -= 1 self.__print_location_if_trace(frame, False) return elif self.step_ignore < 0: # We are stepping only because we tracing self.__print_location_if_trace(frame, False) return if not self.break_here(frame): if bytecode.is_def_stmt(line, frame) and not self.deftrace: self.__print_location_if_trace(frame, False) return elif self.fntrace: # The above test is a real hack. We need to clean # up this code. return else: if not self.break_here(frame) and self.step_ignore > 0: self.__print_location_if_trace(frame, False) self.step_ignore -= 1 return if self.bp_commands(frame): self.interaction(frame, None) return return
def main(): """ Hlavní funkce volána při spuštění """ # == Zpracování parametrů příkazového řádku == arguments = argParse() # == Načtení slovníku do nástroje Figa == figa_handler = figa.marker() figa_handler.load_dict(arguments.figa_dict) # == Testovnání nástroje Figa pomocí souboru "namelist" == with open(arguments.namelist) as fp: error_cnt = 0 error_str = "" for raw_namelist_line in fp: # Parsování řádků ze souboru "namelist" if raw_namelist_line.rstrip("\n") != "": parsed_namelist_line = parseNamelistLine(raw_namelist_line) else: continue # Parsování výstupu z nástroje Figa input_string = parsed_namelist_line.fragment raw_figa_output = figa_handler.lookup_string(input_string) parsed_figa_output = list(parseFigaOutput(raw_figa_output)) # Porovnání řádku ze souboru "namelist" a výstupu z nástroje Figa ok = True if not (len(parsed_figa_output) == 1): # * Pokud nemáme povolený overlap, měl by být výstup právě jeden ok = False error_str = linecache.getline(__file__, inspect.getlineno(inspect.currentframe())-3).strip() elif not (parsed_figa_output[0].start_offset == 0 and len(input_string.decode("utf-8")) == parsed_figa_output[0].end_offset): # * Vstupní fragment by měl odpovídat fragmentu z výstupu nástroje Figa (alespoň délkou) ok = False error_str = linecache.getline(__file__, inspect.getlineno(inspect.currentframe())-3).strip() elif not (parsed_figa_output[0].kb_rows == parsed_namelist_line.kb_rows): # * Řádky KB by měli odpovídat ok = False error_str = linecache.getline(__file__, inspect.getlineno(inspect.currentframe())-3).strip() if not ok: error_cnt += 1 print("=== err. %s ===" % error_cnt) print(error_str) print("<<<<<<<<<") print("NamelistLine(fragment='%s', kb_rows=%s)" % parsed_namelist_line) print("---------") for line in parsed_figa_output: print("FigaOutput(kb_rows=%s, start_offset=%s, end_offset=%s, fragment='%s', flag='%s')" % line) print(">>>>>>>>>")
def info_line(self, arg): """Current line number in source file""" #info line identifier if not self.curframe: self.msg("No line number information available.") return if len(arg) == 2: # lineinfo returns (item, file, lineno) or (None,) answer = self.lineinfo(arg[1]) if answer[0]: item, filename, lineno = answer if not os.path.isfile(filename): filename = fns.search_file(filename, self.search_path, self.main_dirname) self.msg('Line %s of "%s" <%s>' % (lineno, filename, item)) return filename = self.canonic_filename(self.curframe) if not os.path.isfile(filename): filename = fns.search_file(filename, self.search_path, self.main_dirname) self.msg('Line %d of \"%s\" at instruction %d' % (inspect.getlineno( self.curframe), self.filename(self.canonic_filename( self.curframe)), self.curframe.f_lasti)) return False
def run(self, args): """Program counter.""" mainfile = self.core.filename(None) if self.core.is_running(): curframe = self.proc.curframe if curframe: line_no = inspect.getlineno(curframe) offset = curframe.f_lasti self.msg("PC offset is %d." % offset) offset = max(offset, 0) code = curframe.f_code co_code = code.co_code disassemble_bytes(self.msg, self.msg_nocr, co_code, offset, line_no, line_no-1, line_no+1, constants=code.co_consts, cells=code.co_cellvars, varnames=code.co_varnames, freevars=code.co_freevars, linestarts=dict(findlinestarts(code)), end_offset=offset+10) pass pass else: if mainfile: part1 = "Python program '%s'" % mainfile msg = "is not currently running. " self.msg(Mmisc.wrapped_lines(part1, msg, self.settings['width'])) else: self.msg('No Python program is currently running.') pass self.msg(self.core.execution_status) pass return False
def setup(self): """Initialization done before entering the debugger-command loop. In particular we set up the call stack used for local variable lookup and frame/up/down commands. We return True if we should NOT enter the debugger-command loop.""" self.forget() if self.settings('dbg_trepan'): self.frame = inspect.currentframe() pass if self.event in ['exception', 'c_exception']: exc_type, exc_value, exc_traceback = self.event_arg else: exc_type, exc_value, exc_traceback = (None, None, None,) pass if self.frame or exc_traceback: self.stack, self.curindex = \ get_stack(self.frame, exc_traceback, None, self) self.curframe = self.stack[self.curindex][0] self.thread_name = Mthread.current_thread_name() else: self.stack = self.curframe = \ self.botframe = None pass if self.curframe: self.list_lineno = \ max(1, inspect.getlineno(self.curframe) \ - int(self.settings('listsize') / 2)) - 1 else: self.list_lineno = None pass # if self.execRcLines()==1: return True return False
def check(condition): ''' Checks whether the function passed Adds to global pass/fail counters ''' # Only print stack (show full calling function) info if in debug mode if logger.isEnabledFor(logging.DEBUG): parentstack_info = inspect.stack()[-1] logger.debug("{} {}:{}", parentstack_info.code_context[0][:-1], parentstack_info.filename, parentstack_info.lineno) if condition: global test_pass test_pass += 1 else: global test_fail test_fail += 1 # Collect failure info frame = inspect.currentframe().f_back line_file = inspect.getframeinfo(frame).filename line_no = inspect.getlineno(frame) line_info = linecache.getline(line_file, line_no) logger.error("Test failed! {}:{} {}", header(line_file), blued(line_no), line_info[:-1]) # Store info for final report test_fail_info.append((frame, line_file, line_no, line_info))
def _name_process(self, process): if process in self._process_loc: return self._process_loc[process] else: frame = process.gi_frame return "{}:{}".format(inspect.getfile(frame), inspect.getlineno(frame))
def run(self, args): """Program counter.""" proc = self.proc curframe = proc.curframe if curframe: line_no = inspect.getlineno(curframe) offset = curframe.f_lasti self.msg("PC offset is %d." % offset) offset = max(offset, 0) code = curframe.f_code co_code = code.co_code disassemble_bytes( self.msg, self.msg_nocr, code = co_code, lasti = offset, cur_line = line_no, start_line = line_no - 1, end_line = line_no + 1, varnames=code.co_varnames, names=code.co_names, constants=code.co_consts, cells=code.co_cellvars, freevars=code.co_freevars, linestarts=dict(findlinestarts(code)), end_offset=offset + 10, opc=proc.vm.opc, ) pass return False
def run(self, args): """Current line number in source file""" #info line identifier if not self.proc.curframe: self.errmsg("No line number information available.") return if len(args) == 3: # lineinfo returns (item, file, lineno) or (None,) answer = self.lineinfo(args[2]) if answer[0]: item, filename, lineno = answer if not os.path.isfile(filename): filename = Mclifns.search_file(filename, self.core.search_path, self.main_dirname) self.msg('Line %s of "%s" <%s>' % (lineno, filename, item)) return filename = self.core.canonic_filename(self.proc.curframe) if not os.path.isfile(filename): filename = Mclifns.search_file(filename, self.core.search_path, self.main_dirname) pass filename = self.core.canonic_filename(self.proc.curframe) msg1 = 'Line %d of \"%s\"' % (inspect.getlineno( self.proc.curframe), self.core.filename(filename)) msg2 = ('at instruction %d' % self.proc.curframe.f_lasti) if self.proc.event: msg2 += ', %s event' % self.proc.event pass self.msg(Mmisc.wrapped_lines(msg1, msg2, self.settings['width'])) return False
def run(self, args): """Current line number in source file""" # info line identifier if not self.proc.curframe: self.errmsg("No line number information available.") return if len(args) == 3: # lineinfo returns (item, file, lineno) or (None,) answer = self.lineinfo(args[2]) if answer[0]: item, filename, lineno = answer if not os.path.isfile(filename): filename = Mclifns.search_file(filename, self.core.search_path, self.main_dirname) self.msg('Line %s of "%s" <%s>' % (lineno, filename, item)) return filename=self.core.canonic_filename(self.proc.curframe) if not os.path.isfile(filename): filename = Mclifns.search_file(filename, self.core.search_path, self.main_dirname) pass filename = self.core.canonic_filename(self.proc.curframe) msg1 = 'Line %d of \"%s\"' % (inspect.getlineno(self.proc.curframe), self.core.filename(filename)) msg2 = ('at instruction %d' % self.proc.curframe.f_lasti) if self.proc.event: msg2 += ', %s event' % self.proc.event pass self.msg(Mmisc.wrapped_lines(msg1, msg2, self.settings['width'])) return False
def trace_line(self, frame, event, arg): log.info('Trace line') # Note that any C-based function (e.g. max/len etc) # won't actually trigger a call, so we need to see what to do here line = self._getsource(frame) log.info('Line: %s' % line) event_id = self._allocate_event_id() try: # some statements we break up and treat as multiple lines lines = [line] if line.startswith('with'): # this is actually parseable lines = self.convert_with_items_to_lines(line) # using these lines, get any load references load_references = [] for l in lines: if len(l.strip()) > 0: load_references.extend( self.get_load_references_from_line(l)) # using the load references, get the memory locations uses = self.get_mem_locs(load_references, frame, include_global_references=True) # associate all these with the initial line/lineno and store the event trace_event = ExecLine(event_id, inspect.getlineno(frame), line, uses) log.info('Appending trace event: %s' % trace_event) self.push_trace_event(trace_event) except SyntaxError: log.exception('Syntax error while tracing line: %s' % line) # self.trace_errors.append((frame.f_code.co_name, event, arg, line)) return self.trace
def info_line(self, arg): """Current line number in source file""" #info line identifier if not self.curframe: self.msg("No line number information available.") return if len(arg) == 2: # lineinfo returns (item, file, lineno) or (None,) answer = self.lineinfo(arg[1]) if answer[0]: item, filename, lineno = answer if not os.path.isfile(filename): filename = fns.search_file(filename, self.search_path, self.main_dirname) self.msg('Line %s of "%s" <%s>' % (lineno, filename, item)) return filename=self.canonic_filename(self.curframe) if not os.path.isfile(filename): filename = fns.search_file(filename, self.search_path, self.main_dirname) self.msg('Line %d of \"%s\" at instruction %d' % (inspect.getlineno(self.curframe), self.filename(self.canonic_filename(self.curframe)), self.curframe.f_lasti)) return False
def make_line_header(cls): now_time = datetime.datetime.now().time() line_number = inspect.getlineno(inspect.getouterframes(inspect.currentframe())[2][0]) file_path_name = inspect.getfile(inspect.getouterframes(inspect.currentframe())[2][0]) file_name = file_path_name.split('/')[-1] line_header = '[%s] %s:%d : ' % (now_time, file_name, line_number) return line_header
def new_func(*args, **kwargs): try: filename = inspect.getfile(func) except: filename = '?' try: lineno = inspect.getlineno(func) except: lineno = -1 if txt is None: etxt = '' else: etxt = ' ' + txt if expire is not None: if expired: raise Exception("Call to deprecated function {}.{}".format( func.__name__, etxt)) else: warnings.warn_explicit( "Call to deprecated function {} (will expire on {}).{}" .format(func.__name__, expiredate, etxt), category=UserWarning, filename=filename, lineno=lineno, ) else: warnings.warn_explicit( "Call to deprecated function {}.{}".format( func.__name__, etxt), category=UserWarning, filename=filename, lineno=lineno, ) return func(*args, **kwargs)
def __init__(self, depth=0): frame = inspect.stack()[2 + depth] self.filename = child_relpath(inspect.getfile(frame[0])) self.line = inspect.getlineno(frame[0]) self.funcname = frame[0].f_code.co_name try: self.statement = frame[4][0].strip() except TypeError: self.statement = None
def _write_message(self, kind, message): # Get the file/line where this message was generated. f = inspect.currentframe() # Step out of _write_message, and then out of wrapper. f = f.f_back.f_back file = os.path.abspath(inspect.getsourcefile(f)) line = inspect.getlineno(f) sys.stderr.write('%s: %s:%d: %s: %s\n' % (self.progname, file, line, kind, message))
def _name_process(self, process): if process in self._process_loc: return self._process_loc[process] else: if inspect.isgenerator(process): frame = process.gi_frame if inspect.iscoroutine(process): frame = process.cr_frame return "{}:{}".format(inspect.getfile(frame), inspect.getlineno(frame))
def error(cls, message): cls.__find_logs_dir__() logging.basicConfig(filename=cls.FILENAME, level=logging.ERROR, format=cls.FORMAT, datefmt=cls.DATE_FORMAT) frame = inspect.currentframe() line_no = inspect.getlineno(frame) logging.error("ln " + str(line_no) + ": " + message)
def name(self): coroutine = self.coroutine while coroutine.gi_yieldfrom is not None: coroutine = coroutine.gi_yieldfrom if inspect.isgenerator(coroutine): frame = coroutine.gi_frame if inspect.iscoroutine(coroutine): frame = coroutine.cr_frame return "{}:{}".format(inspect.getfile(frame), inspect.getlineno(frame))
def logthis(logline, loglevel=LL.DEBUG, prefix=None, suffix=None, ccode=None): global g_loglevel, handler try: zline = '' if not ccode: if loglevel == LL.ERROR: ccode = C.RED elif loglevel == LL.WARNING: ccode = C.YEL elif loglevel == LL.PROMPT: ccode = C.WHT else: ccode = "" if prefix: zline += C.WHT + str(prefix) + ": " + C.OFF zline += ccode + str(logline) + C.OFF if suffix: zline += " " + C.CYN + str(suffix) + C.OFF # get traceback info lframe = inspect.stack()[1][0] lfunc = inspect.stack()[1][3] mod = inspect.getmodule(lframe) lline = inspect.getlineno(lframe) lfile = inspect.getsourcefile(lframe) try: lfile = os.path.splitext(os.path.basename(lfile))[0] except: lfile = '(error)' if mod: lmodname = str(mod.__name__) xmessage = " " else: lmodname = str(__name__) xmessage = str(data) if lmodname == "__main__": lmodname = "rainwatch" lfunc = "(main)" if g_loglevel > LL.INFO: dbxmod = '%s[%s:%s%s%s:%s] ' % (C.WHT, lmodname, C.YEL, lfunc, C.WHT, lline) else: dbxmod = '' finline = '%s%s<%s>%s %s%s\n' % (dbxmod, C.RED, LL.lname[loglevel], C.WHT, zline, C.OFF) except Exception as e: finline = C.RED + "Exception thrown in logthis(): " + \ C.WHT + "[" + C.YEL + str(e.__class__.__name__) + C.WHT + "] " + \ C.YEL + str(e) + C.OFF + "\n" # write log message if g_loglevel >= loglevel: sys.stdout.write(finline) # write to log target if handler is not None: if handler.ready is True: handler.log(zline, loglevel, mname=lmodname, fname=lfunc, linenum=lline)
def logthis(logline, loglevel=LL.DEBUG, prefix=None, suffix=None, ccode=None, stack_offset=0): """ Global logging function; handles log line composition and prints messages to the console and log file """ # pylint: disable=redefined-outer-name global g_loglevel zline = '' if not ccode: if loglevel == LL.ERROR: ccode = C.RED elif loglevel == LL.WARNING: ccode = C.YEL elif loglevel == LL.PROMPT: ccode = C.WHT else: ccode = "" if prefix: zline += C.WHT + unicode(prefix) + ": " + C.OFF zline += ccode + logline + C.OFF if suffix: zline += " " + C.CYN + unicode(suffix) + C.OFF # get traceback info lframe = inspect.stack()[1 + stack_offset][0] lfunc = inspect.stack()[1 + stack_offset][3] mod = inspect.getmodule(lframe) lline = inspect.getlineno(lframe) lfile = inspect.getsourcefile(lframe) lfile = os.path.splitext(os.path.basename(lfile))[0] if mod: lmodname = str(mod.__name__) else: lmodname = str(__name__) if lmodname == "__main__": lmodname = "yc_cpx" lfunc = "(main)" if g_loglevel > LL.INFO: dbxmod = '%s[%s:%s%s%s:%s] ' % (C.WHT, lmodname, C.YEL, lfunc, C.WHT, lline) else: dbxmod = '' finline = '%s%s<%s>%s %s%s\n' % (dbxmod, C.RED, LL.lname[loglevel], C.WHT, zline, C.OFF) # write log message if g_loglevel >= loglevel: sys.stdout.write(finline) if loglevel <= LL.ERROR: tstatus('error', msg="%s %s" % (logline, suffix))
def run(self, args): """Current line number in source file""" if not self.proc.curframe: self.errmsg("No line number information available.") return # info line <loc> if len(args) == 0: # No line number. Use current frame line number line_number = inspect.getlineno(self.proc.curframe) filename = self.core.canonic_filename(self.proc.curframe) elif len(args) == 1: # lineinfo returns (item, file, lineno) or (None,) line_number, filename = self.lineinfo(args[2:]) if not filename: self.errmsg("Can't parse '%s'" % args[2]) pass filename = self.core.canonic(filename) else: self.errmsg("Wrong number of arguments.") return if not osp.isfile(filename): filename = search_file(filename, self.core.search_path, self.main_dirname) pass line_info = code_line_info(filename, line_number) msg1 = 'Line %d of "%s"' % ( line_number, self.core.filename(filename), ) if line_info: msg2 = "starts at offset %d of %s and contains %d instructions" % ( line_info[0].offsets[0], line_info[0].name, len(line_info[0].offsets), ) self.msg(wrapped_lines(msg1, msg2, self.settings["width"])) else: self.errmsg("No line information for line %d of %s" % (line_number, self.core.filename(filename))) if line_info and len(line_info) > 1: self.msg( wrapped_lines( "There are multiple line offsets for line number.", "Other line offsets: %s" % ", ".join([ "%s of %s" % (li.offsets[0], li.name) for li in line_info[1:] ]), self.settings["width"], )) return False
def findCaller(self): rv = (None, None) frame = inspect.currentframe().f_back while frame: sfn = inspect.getsourcefile(frame) if sfn: sfn = os.path.normcase(sfn) if sfn != _srcfile: lineno = inspect.getlineno(frame) rv = (sfn, lineno) break frame = frame.f_back return rv
def get_source(obj): ''' Get the source code for the frame object ''' filename = inspect.getsourcefile(obj) linecache.checkcache(filename) lineno = inspect.getlineno(obj) prefix = [(linecache.getline(filename, ln) or u'~').strip('\r\n') for ln in range(lineno - 3, lineno)] current = linecache.getline(filename, lineno).strip('\r\n') suffix = [(linecache.getline(filename, ln) or u'~').strip('\r\n') for ln in range(lineno + 1, lineno + 4)] return prefix, current, suffix
def get_source(obj): ''' Get the source code for the frame object ''' filename = inspect.getsourcefile(obj) linecache.checkcache(filename) lineno = inspect.getlineno(obj) prefix = [(linecache.getline(filename, ln) or u'~').strip('\r\n') for ln in range(lineno-3, lineno)] current = linecache.getline(filename, lineno).strip('\r\n') suffix = [(linecache.getline(filename, ln) or u'~').strip('\r\n') for ln in range(lineno+1, lineno+4)] return prefix, current, suffix
def testFiga(i_line, parsed_name_line): # Parsování výstupu z nástroje Figa input_string = parsed_namelist_line.fragment raw_figa_output = figa_handler.lookup_string(input_string) parsed_figa_output = list(parseFigaOutput(raw_figa_output)) # Porovnání řádku ze souboru "namelist" a výstupu z nástroje Figa ok = True if not (len(parsed_figa_output) == 1): # * Pokud nemáme povolený overlap, měl by být výstup právě jeden ok = False error_str = linecache.getline( __file__, inspect.getlineno(inspect.currentframe()) - 3).strip() elif not (parsed_figa_output[0].start_offset == 0 and len(input_string) == parsed_figa_output[0].end_offset): # * Vstupní fragment by měl odpovídat fragmentu z výstupu nástroje Figa (alespoň délkou) ok = False error_str = linecache.getline( __file__, inspect.getlineno(inspect.currentframe()) - 3).strip() elif not (parsed_figa_output[0].kb_rows == parsed_namelist_line.kb_rows): # * Řádky KB by měli odpovídat ok = False error_str = linecache.getline( __file__, inspect.getlineno(inspect.currentframe()) - 3).strip() if not ok: print("=== err. on namelist line %s ===" % i_line) print(error_str) print("<<<<<<<<<") print("NamelistLine(fragment='%s', kb_rows=%s)" % parsed_namelist_line) print("---------") for line in parsed_figa_output: print( "FigaOutput(kb_rows=%s, start_offset=%s, end_offset=%s, fragment='%s', flag='%s')" % line) print(">>>>>>>>>")
def StopManualUpdate(): iStop=15 nRet=Test_TmccSendCommand(iStop,None,None) if (nRet!=0): lineno=inspect.getlineno(inspect.currentframe())+2 WriteDebugLogFile("Send stop command failed",Module_Name,lineno,30)
def setup(self): """Initialization done before entering the debugger-command loop. In particular we set up the call stack used for local variable lookup and frame/up/down commands. We return True if we should NOT enter the debugger-command loop.""" self.forget() if self.settings("dbg_trepan"): self.frame = inspect.currentframe() pass if self.event in ["exception", "c_exception"]: exc_type, exc_value, exc_traceback = self.event_arg else: _, _, exc_traceback = ( None, None, None, ) # NOQA pass if self.frame or exc_traceback: self.stack, self.curindex = get_stack(self.frame, exc_traceback, None, self) self.curframe = self.stack[self.curindex][0] self.thread_name = Mthread.current_thread_name() if exc_traceback: self.list_lineno = traceback.extract_tb(exc_traceback, 1)[0][1] self.list_offset = self.curframe.f_lasti self.list_object = self.curframe else: self.stack = self.curframe = self.botframe = None pass if self.curframe: self.list_lineno = (max( 1, inspect.getlineno(self.curframe) - int(self.settings("listsize") / 2), ) - 1) self.list_offset = self.curframe.f_lasti self.list_filename = self.curframe.f_code.co_filename self.list_object = self.curframe else: self.list_object = None if not exc_traceback: self.list_lineno = None pass # if self.execRcLines()==1: return True # FIXME: do we want to save self.list_lineno a second place # so that we can do 'list .' and go back to the first place we listed? return False
def check(condition, info=None): ''' Checks whether the function passed Adds to global pass/fail counters @param condition: Boolean condition @param info: Additional debugging information @returns: Result of boolean condition ''' # Prepare info info_str = "" if info is not None: info_str = " - {}".format(info) # Only print stack (show full calling function) info if in debug mode if logger.isEnabledFor(logging.DEBUG): parentstack_info = inspect.stack()[-1] logger.debug( "{} {}:{}{}", parentstack_info.code_context[0][:-1], parentstack_info.filename, parentstack_info.lineno, info_str, ) if condition: global test_pass test_pass += 1 else: global test_fail test_fail += 1 # Collect failure info frame = inspect.currentframe().f_back line_file = inspect.getframeinfo(frame).filename line_no = inspect.getlineno(frame) line_info = linecache.getline(line_file, line_no) logger.error( "Test failed! {}:{} {}{}", header(line_file), blued(line_no), line_info[:-1], info_str, ) # Store info for final report test_fail_info.append((frame, line_file, line_no, line_info, info_str)) return condition
def _write_message(self, kind, message): # Get the file/line where this message was generated. f = inspect.currentframe() # Step out of _write_message, and then out of wrapper. f = f.f_back.f_back file = os.path.abspath(inspect.getsourcefile(f)) line = inspect.getlineno(f) sys.stderr.write('%s: %s:%d: %s: %s\n' % (self.progname, file, line, kind, message)) if self.isWindows: # In a git bash terminal, the writes to sys.stderr aren't visible # on screen immediately. Flush them here to avoid broken/misoredered # output. sys.stderr.flush()
def _getsource(self, frame): # we strip before returning the line as # we often use this line to parse a node # and any kind of indentation will lead to SyntaxError raised in ast.parse if self._defined_by_user(frame): log.info('Function is defined by user, fetching source') lineno = inspect.getlineno(frame) return self.src_lines[lineno - 1].strip() # try using inspect if not try: return inspect.getsource(frame).strip() except IOError: log.exception('Unable to retrieve source for frame') return None
def check(condition, info=None): ''' Checks whether the function passed Adds to global pass/fail counters @param condition: Boolean condition @param info: Additional debugging information @returns: Result of boolean condition ''' # Prepare info info_str = "" if info is not None: info_str = " - {}".format(info) # Only print stack (show full calling function) info if in debug mode if logger.isEnabledFor(logging.DEBUG): parentstack_info = inspect.stack()[-1] logger.debug("{} {}:{}{}", parentstack_info.code_context[0][:-1], parentstack_info.filename, parentstack_info.lineno, info_str, ) if condition: global test_pass test_pass += 1 else: global test_fail test_fail += 1 # Collect failure info frame = inspect.currentframe().f_back line_file = inspect.getframeinfo( frame ).filename line_no = inspect.getlineno( frame ) line_info = linecache.getline( line_file, line_no ) logger.error("Test failed! {}:{} {}{}", header(line_file), blued(line_no), line_info[:-1], info_str, ) # Store info for final report test_fail_info.append( (frame, line_file, line_no, line_info, info_str) ) return condition
def be_json_damnit(fn, *args): try: result = fn(*args) return result except Exception as e: for line in traceback.format_stack(): print line.strip() frm = inspect.trace()[-1] f = inspect.getfile(frm[0]) lineno = inspect.getlineno(frm[0]) return HTTPInternalServerError({ 'extras': e.message, 'details': '%s:%s' % (f, lineno) })
def logthis(logline, loglevel=LL.DEBUG, prefix=None, suffix=None, ccode=None): global g_loglevel zline = '' if not ccode: if loglevel == LL.ERROR: ccode = C.RED elif loglevel == LL.WARNING: ccode = C.YEL elif loglevel == LL.PROMPT: ccode = C.WHT else: ccode = "" if prefix: zline += C.WHT + unicode(prefix) + ": " + C.OFF zline += ccode + logline + C.OFF if suffix: zline += " " + C.CYN + unicode(suffix) + C.OFF # get traceback info lframe = inspect.stack()[1][0] lfunc = inspect.stack()[1][3] mod = inspect.getmodule(lframe) lline = inspect.getlineno(lframe) lfile = inspect.getsourcefile(lframe) lfile = os.path.splitext(os.path.basename(lfile))[0] if mod: lmodname = str(mod.__name__) xmessage = " " else: lmodname = str(__name__) xmessage = str(data) if lmodname == "__main__": lmodname = "yc_cpx" lfunc = "(main)" if g_loglevel > LL.INFO: dbxmod = '%s[%s:%s%s%s:%s] ' % (C.WHT, lmodname, C.YEL, lfunc, C.WHT, lline) else: dbxmod = '' finline = '%s%s<%s>%s %s%s\n' % (dbxmod, C.RED, LL.lname[loglevel], C.WHT, zline, C.OFF) # write log message # TODO: add syslog (/dev/log) functionality if g_loglevel >= loglevel: sys.stdout.write(finline) # write to logfile writelog(finline)
def _getCorrectFrame(self): context = 3 frame = sys._getframe(1) # nb: this can be very expensive so we try to do the absolute bare minimum of work here while frame: filename = inspect.getfile(frame) assert filename if filename.endswith('.pyc'): filename = filename[:-3]+'.py' # perform some cross-OS but low cost (no disk access) canonicalization # of the paths if filename.lower().replace('\\','/') == BuildFileLocation._currentBuildFile[-1].lower().replace('\\','/'): lineno = inspect.getlineno(frame) return filename, lineno frame = frame.f_back
def new_func(*args, **kwargs): try: filename = inspect.getfile(func) except BaseException: filename = '?' try: lineno = inspect.getlineno(func) except BaseException: lineno = -1 warnings.warn_explicit( "Call to deprecated function {}.".format(func.__name__), category=UserWarning, filename=filename, lineno=lineno, ) return func(*args, **kwargs)
def setup(self): """Initialization done before entering the debugger-command loop. In particular we set up the call stack used for local variable lookup and frame/up/down commands. We return True if we should NOT enter the debugger-command loop.""" self.forget() if self.settings('dbg_trepan'): self.frame = inspect.currentframe() pass if self.event in ['exception', 'c_exception']: exc_type, exc_value, exc_traceback = self.event_arg else: _, _, exc_traceback = (None, None, None,) # NOQA pass if self.frame or exc_traceback: self.stack, self.curindex = \ get_stack(self.frame, exc_traceback, None, self) self.curframe = self.stack[self.curindex][0] self.thread_name = Mthread.current_thread_name() if exc_traceback: self.list_lineno = traceback.extract_tb(exc_traceback, 1)[0][1] self.list_offset = self.curframe.f_lasti self.list_object = self.curframe else: self.stack = self.curframe = \ self.botframe = None pass if self.curframe: self.list_lineno = \ max(1, inspect.getlineno(self.curframe) - int(self.settings('listsize') / 2)) - 1 self.list_offset = self.curframe.f_lasti self.list_filename = self.curframe.f_code.co_filename self.list_object = self.curframe else: if not exc_traceback: self.list_lineno = None pass # if self.execRcLines()==1: return True # FIXME: do we want to save self.list_lineno a second place # so that we can do 'list .' and go back to the first place we listed? return False
def test_warning_on_instance(self): with warnings.catch_warnings(record=True) as w: Deprecated = create_deprecated_class('Deprecated', NewName, warn_category=MyWarning) class UserClass(Deprecated): pass _, lineno = Deprecated(), inspect.getlineno(inspect.currentframe()) _ = UserClass() self.assertEqual(len(w), 2) msg = w[1] assert issubclass(msg.category, MyWarning) self.assertEqual( str(msg.message), "scrapy.tests.test_utils_deprecate.Deprecated is deprecated, " "instantiate scrapy.tests.test_utils_deprecate.NewName instead." ) self.assertEqual(msg.lineno, lineno)
def run(self, args): proc = self.proc curframe = proc.curframe filename = proc.list_filename if len(args) <= 1: lineno = inspect.getlineno(curframe) else: lineno = proc.get_an_int(args[1], "The 'clear' command argument when given should be " "a line number. Got %s", min_value=1) if lineno is None: return linenos = self.core.bpmgr.delete_breakpoints_by_lineno(filename, lineno) if len(linenos) == 0: self.errmsg("No breakpoint at line %d" % lineno) elif len(linenos) == 1: self.msg("Deleted breakpoint %d" % linenos[0]) elif len(linenos) > 1: self.msg("Deleted breakpoints %s" % ' '.join([str(i) for i in linenos])) return
def test_warning_on_instance(self): Deprecated = create_deprecated_class('Deprecated', NewName, warn_category=MyWarning) # ignore subclassing warnings with warnings.catch_warnings(record=True): class UserClass(Deprecated): pass with warnings.catch_warnings(record=True) as w: _, lineno = Deprecated(), inspect.getlineno(inspect.currentframe()) _ = UserClass() # subclass instances don't warn w = self._mywarnings(w) self.assertEqual(len(w), 1) self.assertEqual( str(w[0].message), "tests.test_utils_deprecate.Deprecated is deprecated, " "instantiate tests.test_utils_deprecate.NewName instead." ) self.assertEqual(w[0].lineno, lineno)
def check( condition ): ''' Checks whether the function passed Adds to global pass/fail counters ''' if condition: global test_pass test_pass += 1 else: global test_fail test_fail += 1 # Collect failure info frame = inspect.currentframe().f_back line_file = inspect.getframeinfo( frame ).filename line_no = inspect.getlineno( frame ) line_info = linecache.getline( line_file, line_no ) print( "{0} Test failed! \033[1;m{1}:\033[1;34m{2}\033[0m {3}".format( ERROR, line_file, line_no, line_info ), end='' ) # Store info for final report test_fail_info.append( (frame, line_file, line_no, line_info) )
def _get_line_number(func): try: return inspect.getlineno(func) except AttributeError: return get_function_code(func).co_firstlineno
def run(self, args): filename, first, last = self.parse_list_cmd(args[1:]) curframe = self.proc.curframe if filename is None: return filename = pyc2py(filename) # We now have range information. Do the listing. max_line = pyficache.size(filename) if max_line is None: self.errmsg('No file %s found' % filename) return canonic_filename = os.path.realpath(os.path.normcase(filename)) if first > max_line: self.errmsg('Bad start line %d - file "%s" has only %d lines' % (first, filename, max_line)) return if last > max_line: self.msg('End position changed to last line %d ' % max_line) last = max_line bplist = self.core.bpmgr.bplist opts = { 'reload_on_change' : self.settings['reload'], 'output' : self.settings['highlight'], 'strip_nl' : False } try: for lineno in range(first, last+1): line = pyficache.getline(filename, lineno, opts) if line is None: line = linecache.getline(filename, lineno, self.proc.frame.f_globals) pass if line is None: self.msg('[EOF]') break else: line = line.rstrip('\n') s = self.proc._saferepr(lineno).rjust(3) if len(s) < 5: s += ' ' if (canonic_filename, lineno,) in list(bplist.keys()): bp = bplist[(canonic_filename, lineno,)][0] a_pad = '%02d' % bp.number s += bp.icon_char() else: s += ' ' a_pad = ' ' pass if curframe and lineno == inspect.getlineno(curframe) \ and filename == curframe.f_code.co_filename: s += '->' if 'plain' != self.settings['highlight']: s = colorize('bold', s) else: s += a_pad pass self.msg(s + '\t' + line) self.proc.list_lineno = lineno pass pass except KeyboardInterrupt: pass return False
def __getCallerInfo(self): sinfo = inspect.stack()[2] module = inspect.getmodule(sinfo[0]).__name__ caller = sinfo[3] lineno = inspect.getlineno(sinfo[0]) return module, caller, lineno
# Create a TestRunParameters Object that contains the details of the test to execute. #Parameters are read in from the command line. testRunParameters = TestRunParameters(workspace = sys.argv[1], project = sys.argv[2], test = sys.argv[3], series = sys.argv[4]) # Create a TestRunner Object testRunner = forecast.createTestRunner(testRunParameters) # Label start of output from script if debugMode == True: print print "\r\n---------- Start of output from %s ----------\r\n" % (os.path.basename(sys.argv[0])) # Print out test run details to the command line print "%s (%s): %s: %s" % (os.path.basename(sys.argv[0]), inspect.getlineno(inspect.currentframe()) , 'WORKSPACE', sys.argv[1]) print "%s (%s): %s: %s" % (os.path.basename(sys.argv[0]), inspect.getlineno(inspect.currentframe()) , 'PROJECT', sys.argv[2]) print "%s (%s): %s: %s" % (os.path.basename(sys.argv[0]), inspect.getlineno(inspect.currentframe()) , 'TEST', sys.argv[3]) print "%s (%s): %s: %s" % (os.path.basename(sys.argv[0]), inspect.getlineno(inspect.currentframe()) , 'SERIES', sys.argv[4]) print "%s (%s): %s: %s" % (os.path.basename(sys.argv[0]), inspect.getlineno(inspect.currentframe()) , 'RUN NUMBER', testRunner.getRunNumber()) print "%s (%s): %s: %s" % (os.path.basename(sys.argv[0]), inspect.getlineno(inspect.currentframe()) , 'RUN PATH', testRunner.getRunPath()) print "\r\n----------- End of output from %s -----------\r\n" % (os.path.basename(sys.argv[0])) eventlogfile = testRunner.getRunPath() + "\\localhost\\intel.win32.clr4_5.0\\scratch\\QMmetrics.txt" historyfile = os.getcwd() + "\\QMmetrics.csv" if debugMode == True: print "%s" % (time.strftime("%c")) print "Event log file: %s\r" % (eventlogfile) os.environ["EPPLOGFILE"] = eventlogfile
def parse_list_cmd(self, args): """Parses arguments for the "list" command and returns the tuple: filename, start, last or sets these to None if there was some problem.""" dbg_obj = self.core.debugger proc = self.proc curframe = proc.curframe filename = proc.list_filename last = None listsize = dbg_obj.settings['listsize'] if len(args) == 0 and not curframe: self.errmsg("No Python program loaded.") return (None, None, None) if len(args) > 0: if args[0] == '-': first = max(1, proc.list_lineno - 2*listsize - 1) elif args[0] == '.': filename = curframe.f_code.co_filename first = max(1, inspect.getlineno(curframe) - int(listsize/2)) else: (modfunc, filename, first) = proc.parse_position(args[0]) if first is None and modfunc is None: # error should have been shown previously return (None, None, None) if len(args) == 1: if first is None and modfunc is not None: first = 1 first = max(1, first - int(listsize/2)) elif len(args) == 2 or (len(args) == 3 and modfunc): msg = 'Starting line expected, got %s.' % args[-1] num = proc.get_an_int(args[1], msg) if num is None: return (None, None, None) if modfunc: if first is None: first = num if len(args) == 3 and modfunc: msg = ('last or count parameter expected, ' + 'got: %s.' % args[2]) last = proc.get_an_int(args[2], msg) pass pass else: last = num pass else: last = num pass if last is not None and last < first: # Assume last is a count rather than an end line number last = first + last - 1 pass pass elif not modfunc: self.errmsg(('At most 2 parameters allowed when no ' 'module name is found/given. Saw: %d ' 'parameters') % len(args)) return (None, None, None) else: self.errmsg(('At most 3 parameters allowed when a module' + ' name is given. Saw: %d parameters') % len(args)) return (None, None, None) pass elif proc.list_lineno is None and self.core.is_running(): first = max(1, inspect.getlineno(curframe) - int(listsize/2)) else: first = proc.list_lineno + 1 pass if last is None: last = first + listsize - 1 pass proc.list_filename = filename return (filename, first, last)
def resolve_location(proc, location, canonic=True): """Expand fields in Location namedtuple. If: '.': get fields from stack function/module: get fields from evaluation/introspection location file and line number: use that """ curframe = proc.curframe if location == '.': if not curframe: proc.errmsg("Don't have a stack to get location from") return INVALID_LOCATION filename = Mstack.frame2file(proc.core, curframe, canonic=canonic) lineno = inspect.getlineno(curframe) return Location(filename, lineno, False, None) assert isinstance(location, Location) is_address = False if proc.curframe: g = curframe.f_globals l = curframe.f_locals else: g = globals() l = locals() pass if location.method: # Validate arguments that can't be done in parsing filename = lineno = None msg = ('Object %s is not known yet as a function, ' % location.method) try: modfunc = eval(location.method, g, l) except: proc.errmsg(msg) return INVALID_LOCATION try: # Check if the converted string is a function or instance method if inspect.isfunction(modfunc) or hasattr(modfunc, 'im_func'): pass else: proc.errmsg(msg) return INVALID_LOCATION except: proc.errmsg(msg) return INVALID_LOCATION filename = proc.core.canonic(modfunc.func_code.co_filename) # FIXME: we may want to check lineno and # respect that in the future lineno = modfunc.func_code.co_firstlineno elif location.path: filename = proc.core.canonic(location.path) lineno = location.line_number modfunc = None msg = "%s is not known as a file" % location.path if not osp.isfile(filename): # See if argument is a module try: modfunc = eval(location.path, g, l) except: msg = ("Don't see '%s' as a existing file or as an module" % location.path) proc.errmsg(msg) return INVALID_LOCATION pass is_address = location.is_address if inspect.ismodule(modfunc): if hasattr(modfunc, '__file__'): filename = pyficache.pyc2py(modfunc.__file__) filename = proc.core.canonic(filename) if not lineno: # use first line of module file lineno = 1 is_address = False return Location(filename, lineno, is_address, modfunc) else: msg = ("module '%s' doesn't have a file associated with it" % location.path) proc.errmsg(msg) return INVALID_LOCATION maxline = pyficache.maxline(filename) if maxline and lineno > maxline: # NB: we use the gdb wording here proc.errmsg("Line number %d out of range; %s has %d lines." % (lineno, filename, maxline)) return INVALID_LOCATION elif location.line_number: filename = Mstack.frame2file(proc.core, curframe, canonic=canonic) lineno = location.line_number is_address = location.is_address modfunc = None return Location(filename, lineno, is_address, modfunc)
def ManualUpdate(): lineno=inspect.getlineno(inspect.currentframe())+2 WriteDebugLogFile("Enter into the manual updte function",Module_Name,lineno,90) iCommand=14 #command:start manual update iStop=15 #command:stop manual update bSkedUpdate=0 iRunning=0 #update status iUPPercent=0 #update percent iUPStatus=0 #update result bRet=1 bNeedReload=False bFirst=False MAX_EXE_COUNT=20000 #for recorder the result global RunningStatus TmccAUStatus=Test_TmccGetUpdateStatus(0) #print TmccAUStatus iRunning=TmccAUStatus[0] #print iRunning try: if iRunning==2 or iRunning==4: bRet=Test_TmccSendCommand(iStop,None,None) if bRet==0: lineno=inspect.getlineno(inspect.currentframe())+2 WriteDebugLogFile("The still running update process is stopped now",Module_Name,lineno,90) else: lineno=inspect.getlineno(inspect.currentframe())+2 WriteDebugLogFile("The running update process can't be stopped",Module_Name,lineno,30) time.sleep(2) #print "enter" bRet=Test_TmccSendCommand(iCommand,None,None) #print bRet if bRet<>0: #print "enter bRet<>0" lineno=inspect.getlineno(inspect.currentframe())+2 WriteDebugLogFile("The manual update command is sent to the core module unsuccussfully",\ Module_Name,lineno,30) return False iExeNum=0 while 1: time.sleep(1) nRet=0 TmccAUStatus=Test_TmccGetUpdateStatus(0) if TmccAUStatus==None: lineno=inspect.getlineno(inspect.currentframe())+2 #print "Calling getupdatestatus function failed" WriteDebugLogFile("Calling getupdatestatus function failed",\ Module_Name,lineno,30) return False iRunning=TmccAUStatus[0] RunningStatus=iRunning iUPPercent=TmccAUStatus[1] iUPStatus=TmccAUStatus[2] #print "iRunning:",iRunning if iRunning==4 and iUPPercent==100: lineno=inspect.getlineno(inspect.currentframe())+2 WriteDebugLogFile("The manual update is finished successfully",Module_Name,lineno,90) GetPatternVersion() ##write the pattern file to get the version info break elif iRunning==2: #running if bFirst==False: lineno=inspect.getlineno(inspect.currentframe())+2 WriteDebugLogFile("The manual update is started ",Module_Name,lineno,90) bFirst=True elif iRunning==5: if bFirst==True: lineno=inspect.getlineno(inspect.currentframe())+2 WriteDebugLogFile("The download is finished ",Module_Name,lineno,90) bFirst=False elif iRunning==6:###TMCC_TASK_AU_DOWNLOAD_FINISHED if bFirst==False: lineno=inspect.getlineno(inspect.currentframe())+2 WriteDebugLogFile("The download is finished and need to reload ",Module_Name,lineno,90) bFirst=True time.sleep(120) bNeedReload=True status=Test_TmccGetUpdateStatus() # miss paramter "0" iRunning=status[0] iUPPercent=status[1] iUPStatus=status[2] if iRunning==0 and iUPPercent==0 and iUPStatus==0: lineno=inspect.getlineno(inspect.currentframe())+2 WriteDebugLogFile("The update s finished ",Module_Name,lineno,90) break elif iRunning==7: lineno=inspect.getlineno(inspect.currentframe())+2 print "The update meets errors, error number:",iUPStatus,Module_Name WriteDebugLogFile("The update meets errors, error number:%d " %iUPStatus,\ Module_Name,lineno,30) return -1 iExeNum=iExeNum+1 if iExeNum>MAX_EXE_COUNT: WriteDebugLogFile("iExeNum",iExeNum,lineno,30) WriteDebugLogFile("MAX_EXE_COUNT",MAX_EXE_COUNT,lineno,30) lineno=inspect.getlineno(inspect.currentframe())+2 #print "The update is timeout " WriteDebugLogFile("The update is timeout ",Module_Name,lineno,30) break return 0 except RuntimeError,e: print e
def _get_line_number(func): try: return inspect.getlineno(func) except AttributeError: return func.func_code.co_firstlineno
def trace_dispatch(self, frame, event, arg): """Called from Python when some event-like stepping or returning occurs """ # The below variable will be used to scan down frames to determine # if trace_dispatch has been called. We key on the variable # name, method name, type of variable and even the value. # Note this is the first statement of this method. breadcrumb = is_in_threaddbg_dispatch # There's some locking interaction between this code and # threading code which can cause a deadlock. So avoid the # problem rather than try to cope with it - don't trace # into threading. # FIXME: the below code is not clean or reliable. # Make more like is_in_threaddbg try: # "inspect" can return IOError, and on some version of # Python 2.4 inspect has raises an IndexError see # bug #1673507 (filename, line_no, routine) = inspect.getframeinfo(frame)[0:3] except: return self.trace_dispatch (path, basename)=os.path.split(filename) if basename.startswith('threading.py'): return self.trace_dispatch # Note: until locking is done below we should not update and # save self.thread_name and self.thread_id but use # threading.currentThread().getname and thread.get_ident() instead. last_thread_id = self.thread_id # Record in my own table a list of thread names if not threading.currentThread().getName() in self.traced.keys(): self.traced[threading.currentThread().getName()] = \ thread.get_ident() have_single_entry_lock = False while not self._user_requested_quit: # See if there was a request to switch to a specific thread while self.desired_thread is not None \ and self.thread_name not in self.desired_thread: self.threading_cond.acquire() self.threading_cond.wait() self.threading_cond.release() # One at a time, please. self.threading_lock.acquire() have_single_entry_lock = True if self.desired_thread is None \ or threading.currentThread().getName() in self.desired_thread: break if self._user_requested_quit: break self.threading_lock.release() if self.desired_thread != None: # We are switching from another thread # If a breakpoint isn't set at the current # location, we should set up a temporary # breakpoint. if not self.stop_here(self.setup(frame)): arg = str(inspect.getlineno(frame)) self.do_tbreak(arg) self.desired_thread = None if self._user_requested_quit: self.msg("%s (id %ld) is quitting." % (threading.currentThread().getName(), thread.get_ident())) if have_single_entry_lock: self.threading_lock.release() thread.exit() return # Because of locks above there should not be any chance # that the following assignments will change during the course # of debugger command loop. self.curframe_thread_name = self.thread_name = \ threading.currentThread().getName() self.thread_id = thread.get_ident() if self.linetrace: # self.msg("thread %s event %s" % (thread_name, event)) self.setup(frame) self.print_location() else: while True: try: if self.stepping and last_thread_id != thread.get_ident(): botframe = self.botframe self.botframe = frame #print "Thread switch %s %d %d" % (self.thread_name, # last_thread_id, # self.thread_id) self.nothread_trace_dispatch(self, frame, event, arg) break except Restart: sys.argv = list(self._program_sys_argv) self.msg("'run' command not implemented for thread " + "debugging. Try 'restart'.") # self.msg("Should Restart %s with arguments:\n\t%s" # % (self.filename(sys.argv[0]), # " ".join(self._program_sys_argv[1:]))) except bdb.BdbQuit: self.msg("Requesting exit from %s (id %ld)" % (threading.currentThread().getName(), thread.get_ident())) self._user_requested_quit = True self.desired_thread = None self.threading_cond.acquire() self.threading_cond.notify() self.threading_cond.release() self.threading_lock.release() thread.exit() return self.threading_lock.release() return self.trace_dispatch