• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python traceback.print_list函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中traceback.print_list函数的典型用法代码示例。如果您正苦于以下问题:Python print_list函数的具体用法?Python print_list怎么用?Python print_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了print_list函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: print_stack

    def print_stack(self, *, limit=None, file=None):
        """Print the stack or traceback for this task's coroutine.

        This produces output similar to that of the traceback module,
        for the frames retrieved by get_stack().  The limit argument
        is passed to get_stack().  The file argument is an I/O stream
        to which the output is written; by default output is written
        to sys.stderr.
        """
        extracted_list = []
        checked = set()
        for f in self.get_stack(limit=limit):
            lineno = f.f_lineno
            co = f.f_code
            filename = co.co_filename
            name = co.co_name
            if filename not in checked:
                checked.add(filename)
                linecache.checkcache(filename)
            line = linecache.getline(filename, lineno, f.f_globals)
            extracted_list.append((filename, lineno, name, line))
        exc = self._exception
        if not extracted_list:
            print('No stack for %r' % self, file=file)
        elif exc is not None:
            print('Traceback for %r (most recent call last):' % self,
                  file=file)
        else:
            print('Stack for %r (most recent call last):' % self,
                  file=file)
        traceback.print_list(extracted_list, file=file)
        if exc is not None:
            for line in traceback.format_exception_only(exc.__class__, exc):
                print(line, file=file, end='')
开发者ID:lunixbochs,项目名称:actualvim,代码行数:34,代码来源:tasks.py


示例2: handler

def handler(signum, frame):
    limit = None
    file = None
    traceback.print_list(traceback.extract_stack(frame, limit=limit), file=file)
    print(signum, frame)
    print(dir(frame))
    sys.exit(-1)
开发者ID:podhmo,项目名称:individual-sandbox,代码行数:7,代码来源:00loop.py


示例3: __call__

    def __call__(self, *args):
        assert len(args) == len(self.input_types), "Wrong number of inputs provided"
        self.args = tuple(core.as_valid_array(arg, intype) for (arg, intype) in zip(args, self.input_types))
        for instr in self.eg.instrs:
            if profiler.on: tstart = time.time()
            try:
                instr.fire(self)
            except Exception as e:
                traceback.print_exc()
                if isinstance(instr, (ReturnByRef,ReturnByVal)):
                    if core.get_config()["debug"]:
                        assert "stack" in instr.node_props
                        utils.colorprint(utils.Color.MAGENTA, "HERE'S THE STACK WHEN THE OFFENDING NODE WAS CREATED\n",o=sys.stderr)
                        print>>sys.stderr, ">>>>>>>>>>>>>>>>>>>>>>>>>>"        
                        traceback.print_list(instr.node_props["stack"])
                        print>>sys.stderr, "<<<<<<<<<<<<<<<<<<<<<<<<<<"        
                        raise e
                    else:
                        utils.error("Didn't save the stack so I can't give you a nice traceback :(. Try running with CGT_FLAGS=debug=True")
                        raise e
                else:
                    utils.error("Oy vey, an exception occurred in a %s Instruction. I don't know how to help you debug this one right now :(."%type(instr))
                    raise e

            if profiler.on: profiler.update(instr, time.time()-tstart)
        outputs = [self.get(loc) for loc in self.output_locs]
        if self.copy_outputs: outputs = map(_copy, outputs)
        return outputs
开发者ID:jameshensman,项目名称:cgt,代码行数:28,代码来源:compilation.py


示例4: _task_print_stack

def _task_print_stack(task, limit, file):
    extracted_list = []
    checked = set()
    for f in task.get_stack(limit=limit):
        lineno = f.f_lineno
        co = f.f_code
        filename = co.co_filename
        name = co.co_name
        if filename not in checked:
            checked.add(filename)
            linecache.checkcache(filename)
        line = linecache.getline(filename, lineno, f.f_globals)
        extracted_list.append((filename, lineno, name, line))

    exc = task._exception
    if not extracted_list:
        print('No stack for {!r}'.format(task), file=file)
    elif exc is not None:
        print('Traceback for {!r} (most recent call last):'.format(task), file=file)
    else:
        print('Stack for {!r} (most recent call last):'.format(task), file=file)

    traceback.print_list(extracted_list, file=file)
    if exc is not None:
        for line in traceback.format_exception_only(exc.__class__, exc):
            print(line, file=file, end='')
开发者ID:wwqgtxx,项目名称:wwqLyParse,代码行数:26,代码来源:base_tasks.py


示例5: stacktrace

    def stacktrace():
        buf = cStringIO.StringIO()

        stack = traceback.extract_stack()
        traceback.print_list(stack[:-2], file=buf)

        stacktrace_string = buf.getvalue()
        buf.close()
        return stacktrace_string
开发者ID:CVO-Technologies,项目名称:ipsilon,代码行数:9,代码来源:log.py


示例6: new_test

def new_test():
    p = PssAnalyzer()
    
    folder = os.path.join(os.getcwd(),"run_files")
    folder = os.path.join(folder,"uniqes")
    
    p.appent_pattern(folder, ".*best.*")
    r = p.solved_percent_ext()
    
    print_list(r)
开发者ID:hizki,项目名称:AI1,代码行数:10,代码来源:analyzer.py


示例7: dump

 def dump(cls, label):
     df = cls.dump_file or sys.stderr
     s = StringIO()
     print >>s, "\nDumping thread %s:" % (label, )
     try:
         raise ZeroDivisionError
     except ZeroDivisionError:
         f = sys.exc_info()[2].tb_frame.f_back.f_back
     traceback.print_list(traceback.extract_stack(f, None), s)
     df.write(s.getvalue())
开发者ID:Glottotopia,项目名称:aagd,代码行数:10,代码来源:thread_monitor.py


示例8: test_print_list

def test_print_list():
    expected_string = u"""  vi +21 traceback/tests.py  # _triple
    one()
  vi +11 traceback/tests.py  # one
    two()
  vi +10 traceback/tests.py  # two
    h[1]
"""
    out = StringIO()
    print_list(extract_tb(_tb()), file=out)
    eq_(out.getvalue(), expected_string)
开发者ID:erikrose,项目名称:tracefront,代码行数:11,代码来源:tests.py


示例9: test_unsolved

def test_unsolved():
    p = PssAnalyzer()
    folder = os.path.join(os.getcwd(),"run_files")
    folder = os.path.join(folder,"uniqes")
    
    p.appent_pattern(folder, ".*beam.*")
    
    #p = p.select("AnytimeBest-d250_with_PowerHeuristic2")
    #p = p.select("AnytimeBeam-w20-.*")
    
    print "unsolved_rooms"
    unsolved_rooms = p.get_unsolved_rooms(roomset="heavy_roomset")
    print_list(unsolved_rooms)  
开发者ID:hizki,项目名称:AI1,代码行数:13,代码来源:analyzer.py


示例10: __init__

 def __init__(self, *args, **kwargs):
     if kwargs:
         # The call to list is needed for Python 3
         assert list(kwargs.keys()) == ["variable"]
         tr = getattr(list(kwargs.values())[0].tag, "trace", [])
         if type(tr) is list and len(tr) > 0:
             sio = StringIO()
             print("\nBacktrace when the variable is created:", file=sio)
             for subtr in list(kwargs.values())[0].tag.trace:
                 traceback.print_list(subtr, sio)
             args = args + (str(sio.getvalue()),)
     s = "\n".join(args)  # Needed to have the new line print correctly
     Exception.__init__(self, s)
开发者ID:cfsmile,项目名称:Theano,代码行数:13,代码来源:fg.py


示例11: t

def t():
    p = PssAnalyzer()
    p.load_bstf()
    r = p.solved_percent()
    name,_ = do_by_key(max,r,1)
    pss = p.select_first(name,'.*stat.*')
    
    print pss.roomset.name
    print pss.name
    print pss.solutions    
    t = p.room_id_with_runtime_table(pss)
    print_list( do_by_key(sorted,t,1) )
    return r
开发者ID:hizki,项目名称:AI1,代码行数:13,代码来源:analyzer.py


示例12: test_solution_improvment

def test_solution_improvment():
    p = PssAnalyzer()
    folder = os.path.join(os.getcwd(),"run_files")
    folder = os.path.join(folder,"uniqes")
    
    p.appent_pattern(folder, ".*")
    #p.appent_pattern(folder, ".*limit.*")
    
    #p = p.select("AnytimeBest-d250_with_PowerHeuristic2")
    #p = p.select(".*", roomset_pattern="heavy_roomset")
    
    l = p.solution_imp()
    print_list(l)
    print len(l), "from", p.rooms_count()
开发者ID:hizki,项目名称:AI1,代码行数:14,代码来源:analyzer.py


示例13: error

 def error(key, include_traceback=False):
   exc_type, exc_value, _ = sys.exc_info()
   msg = StringIO()
   if include_traceback:
     frame = inspect.trace()[-1]
     filename = frame[1]
     lineno = frame[2]
     funcname = frame[3]
     code = ''.join(frame[4])
     traceback.print_list([(filename, lineno, funcname, code)], file=msg)
   if exc_type:
     msg.write(''.join(traceback.format_exception_only(exc_type, exc_value)))
   errors[key] = msg.getvalue()
   sys.exc_clear()
开发者ID:soheilhy,项目名称:commons,代码行数:14,代码来源:goal.py


示例14: print_exception

def print_exception():
    flush_stdout()
    efile = sys.stderr
    typ, val, tb = excinfo = sys.exc_info()
    sys.last_type, sys.last_value, sys.last_traceback = excinfo
    tbe = traceback.extract_tb(tb)
    print>>efile, '\nTraceback (most recent call last):'
    exclude = ("run.py", "rpc.py", "threading.py", "Queue.py",
               "RemoteDebugger.py", "bdb.py")
    cleanup_traceback(tbe, exclude)
    traceback.print_list(tbe, file=efile)
    lines = traceback.format_exception_only(typ, val)
    for line in lines:
        print>>efile, line,
开发者ID:B-Rich,项目名称:breve,代码行数:14,代码来源:run.py


示例15: get_variable_trace_string

def get_variable_trace_string(v):
    sio = StringIO()
    # For backward compatibility with old trace
    tr = getattr(v.tag, 'trace', [])
    if isinstance(tr, list) and len(tr) > 0:
        print(" \nBacktrace when that variable is created:\n", file=sio)
        # The isinstance is needed to handle old pickled trace
        if isinstance(tr[0], tuple):
            traceback.print_list(v.tag.trace, sio)
        else:
            # Print separate message for each element in the list of
            # batcktraces
            for subtr in tr:
                traceback.print_list(subtr, sio)
    return sio.getvalue()
开发者ID:12190143,项目名称:Theano,代码行数:15,代码来源:utils.py


示例16: loadFile

    def loadFile(self,relFilePath):
        self.unLoadFile(relFilePath)

        f = QFile(self.directory.absolutePath() + '/' + relFilePath)
        if(f.open(QIODevice.ReadOnly)):
            fileContents=QString(f.readAll().toBase64())
            self.hashValue.reset()
            self.hashValue.addData(fileContents)
            self.fileBuffer[relFilePath]=fileContents,QString(self.hashValue.result().toHex())
            #print "fileBuffer status: \n",self.fileBuffer
            #print "Alert: Loaded :", self.fileBuffer[fileName]
            return True
        else:
            print "Error: loadFile failed -> couldn't open: ", f.fileName()
            traceback.print_list(traceback.extract_stack())
            return False
开发者ID:bhanuvrat,项目名称:FShaSynApp,代码行数:16,代码来源:connection.py


示例17: print_exception

def print_exception():
    import linecache

    linecache.checkcache()
    flush_stdout()
    efile = sys.stderr
    typ, val, tb = excinfo = sys.exc_info()
    sys.last_type, sys.last_value, sys.last_traceback = excinfo
    tbe = traceback.extract_tb(tb)
    print("Traceback (most recent call last):", file=efile)
    exclude = ("run.py", "rpc.py", "threading.py", "queue.py", "RemoteDebugger.py", "bdb.py")
    cleanup_traceback(tbe, exclude)
    traceback.print_list(tbe, file=efile)
    lines = traceback.format_exception_only(typ, val)
    for line in lines:
        print(line, end="", file=efile)
开发者ID:Anzumana,项目名称:cpython,代码行数:16,代码来源:run.py


示例18: print_stack

def print_stack(task):
        extracted_list = []
        checked = set()
        for f in get_stack(task):
            lineno = f.f_lineno
            co = f.f_code
            filename = co.co_filename
            name = co.co_name
            if filename not in checked:
                checked.add(filename)
                linecache.checkcache(filename)
            line = linecache.getline(filename, lineno, f.f_globals)
            extracted_list.append((filename, lineno, name, line))
        if not extracted_list:
            print('No stack for %r' % task)
        else:
            print('Stack for %r (most recent call last):' % task)
        traceback.print_list(extracted_list)
开发者ID:Hellowlol,项目名称:curio,代码行数:18,代码来源:monitor.py


示例19: _get_test_value

    def _get_test_value(cls, v):
        """
        Extract test value from variable v. Raises AttributeError if there is none.

        For a Constant, the test value is v.value.
        For a Shared variable, it is the internal value.
        For another Variable, it is the content of v.tag.test_value.
        """
        # avoid circular import
        from theano.compile.sharedvalue import SharedVariable

        if isinstance(v, graph.Constant):
            return v.value
        elif isinstance(v, SharedVariable):
            return v.get_value(borrow=True, return_internal_type=True)
        elif isinstance(v, graph.Variable) and hasattr(v.tag, 'test_value'):
            # ensure that the test value is correct
            try:
                ret = v.type.filter(v.tag.test_value)
            except Exception as e:
                # Better error message.
                detailed_err_msg = (
                    "For compute_test_value, one input test value does not"
                    " have the requested type.\n")
                tr = getattr(v.tag, 'trace', None)
                if tr:
                    sio = StringIO.StringIO()
                    traceback.print_list(tr, sio)
                    tr = sio.getvalue()
                    detailed_err_msg += (
                        " \nBacktrace when that variable is created:\n")
                    detailed_err_msg += str(tr)
                detailed_err_msg += (
                    "\nThe error when converting the test value to that"
                    " variable type:")
                # We need to only have 1 args and it should be of type
                # string.  Otherwise, it print the tuple and so the
                # new line do not get printed.
                args = (detailed_err_msg,) + tuple(str(arg) for arg in e.args)
                e.args = ("\n".join(args),)
                raise
            return ret

        raise AttributeError('%s has no test value' % v)
开发者ID:alimuldal,项目名称:Theano,代码行数:44,代码来源:op.py


示例20: print_exception

def print_exception(source = None, filename = None):
    import linecache
    linecache.checkcache()
    flush_stdout()
    efile = sys.stderr
    typ, val, tb = excinfo = sys.exc_info()
    sys.last_type, sys.last_value, sys.last_traceback = excinfo
    tbe = traceback.extract_tb(tb)
    print>>efile, '\nTraceback (most recent call last):'
    exclude = ("run.py", "rpc.py", "threading.py", "Queue.py",
               "RemoteDebugger.py", "bdb.py", "Commands.py")
    cleanup_traceback(tbe, exclude)
    add_exception_link(tbe)
    traceback.print_list(tbe, file=efile)
    lines = traceback.format_exception_only(typ, val)
    for line in lines:
        print>>efile, line,
    if source is not None and filename is not None:
       Suggest.exception_suggest(typ, val, tb, source, filename)
开发者ID:alonti,项目名称:idlespork,代码行数:19,代码来源:run.py



注:本文中的traceback.print_list函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python traceback.print_stack函数代码示例发布时间:2022-05-27
下一篇:
Python traceback.print_exception函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap