当前位置: 首页>>代码示例>>Python>>正文


Python sys.exc_traceback方法代码示例

本文整理汇总了Python中sys.exc_traceback方法的典型用法代码示例。如果您正苦于以下问题:Python sys.exc_traceback方法的具体用法?Python sys.exc_traceback怎么用?Python sys.exc_traceback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sys的用法示例。


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

示例1: verifyStderr

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_traceback [as 别名]
def verifyStderr(self, method, successRe) :
        """
        Call method() while capturing sys.stderr output internally and
        call self.fail() if successRe.search() does not match the stderr
        output.  This is used to test for uncatchable exceptions.
        """
        stdErr = sys.stderr
        sys.stderr = StringIO()
        try:
            method()
        finally:
            temp = sys.stderr
            sys.stderr = stdErr
            errorOut = temp.getvalue()
            if not successRe.search(errorOut) :
                self.fail("unexpected stderr output:\n"+errorOut)
        if sys.version_info < (3, 0) :  # XXX: How to do this in Py3k ???
            sys.exc_traceback = sys.last_traceback = None 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:20,代码来源:test_compare.py

示例2: test_str2

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_traceback [as 别名]
def test_str2(self):
        # verify we can assign to sys.exc_*
        sys.exc_traceback = None
        sys.exc_value = None
        sys.exc_type = None

        self.assertEqual(str(Exception()), '')


        @skipUnlessIronPython()
        def test_array(self):
            import System
            try:
                a = System.Array()
            except Exception, e:
                self.assertEqual(e.__class__, TypeError)
            else: 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_exceptions.py

示例3: traceback_get_exception

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_traceback [as 别名]
def traceback_get_exception(num = -1):

    # build error message
    exception_string = ''.join(traceback.format_exception_only(sys.exc_type, hasattr(sys, 'exc_value') and sys.exc_value or 'Unknown'))

    # extract error location from traceback
    if hasattr(sys, 'exc_traceback'):
        (filename, line_number, function_name, text) = traceback.extract_tb(sys.exc_traceback)[num]
    else:
        (filename, line_number, function_name, text) = ('-', '-', '-', '-')

    error = {
        'message': exception_string,
        'location': {
            'filename': filename,
            'line_number': line_number,
            'function_name': function_name,
            'text': text,
            }
    }

    return error 
开发者ID:daq-tools,项目名称:kotori,代码行数:24,代码来源:errors.py

示例4: run_campaign

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_traceback [as 别名]
def run_campaign(test_campaign, get_interactive_session, verb=2):
    passed=failed=0
    if test_campaign.preexec:
        test_campaign.preexec_output = get_interactive_session(test_campaign.preexec.strip())[0]
    for testset in test_campaign:
        for t in testset:
            t.output,res = get_interactive_session(t.test.strip())
            the_res = False
            try:
                if res is None or res:
                    the_res= True
            except Exception,msg:
                t.output+="UTscapy: Error during result interpretation:\n"
                t.output+="".join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback,))
            if the_res:
                t.res = True
                res = "passed"
                passed += 1
            else:
                t.res = False
                res = "failed"
                failed += 1
            t.result = res
            if verb > 1:
                print >>sys.stderr,"%(result)6s %(crc)s %(name)s" % t 
开发者ID:medbenali,项目名称:CyberScan,代码行数:27,代码来源:UTscapy.py

示例5: __init__

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_traceback [as 别名]
def __init__(self, path = None):
        self.version = 1
        self.fragments = []
        self.path = path
        if path is not None and os.path.exists(path):
            currentresref = Res.CurResFile()
            resref = Res.FSpOpenResFile(path, 1)
            Res.UseResFile(resref)
            try:
                try:
                    data = Res.Get1Resource('cfrg', 0).data
                except Res.Error:
                    raise Res.Error, "no 'cfrg' resource found", sys.exc_traceback
            finally:
                Res.CloseResFile(resref)
                Res.UseResFile(currentresref)
            self.parse(data)
            if self.version != 1:
                raise error, "unknown 'cfrg' resource format" 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:21,代码来源:cfmfile.py

示例6: _get_assigned_letters

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_traceback [as 别名]
def _get_assigned_letters(self, cr, uid, ids, prop, unknow_none, context=None):
        if not len(ids):
            return {}
        model_name = super(hr_employee, self)._name
        res = []
        try:
            for id in ids:
                letter_ids = []
                ref_ids = self.pool['letter.ref'].search(cr, uid, [('int_ref', '=', model_name + ',' + str(id))],
                                                         context=context)
                if ref_ids:
                    for ref in self.pool['letter.ref'].read(cr, uid, ref_ids, context=context):
                        letter_ids.append(ref['letter_id'][0])
                res.append((id, letter_ids))
        except Exception, e:
            _logger.error(repr(traceback.extract_tb(sys.exc_traceback))) 
开发者ID:iw3hxn,项目名称:LibrERP,代码行数:18,代码来源:inherit_hr_employee.py

示例7: ExecutePythonString

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_traceback [as 别名]
def ExecutePythonString(self, text):
        try:
            try:
                return eval(text, globals(), self.GetLocals())
            except SyntaxError:
                tb = sys.exc_traceback
                if tb.tb_next is None:
                    exec text in self.GetLocals()
                else:
                    raise
        except NameError as e:
            tb = sys.exc_traceback
            if tb.tb_next and tb.tb_next.tb_next is None:
                log("Error: {0}\n", e.args[0])
            else:
                raise 
开发者ID:TechInvestLab,项目名称:dot15926,代码行数:18,代码来源:environment.py

示例8: test_actors

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_traceback [as 别名]
def test_actors(self):
        test_pass = []
        test_fail = {}
        no_test = []

        for actor in self.actors:
            aut = self.actors[actor]
            if aut == "no_test":
                no_test.append(actor)
                continue
            try:
                self.test_actor(actor, aut)
                test_pass.append(actor)
            except AssertionError as e:
                test_fail[actor] = e.message
            except Exception as e:
                self.illegal_actors[actor] = str(e) + '\n' + ''.join(
                    traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))

        return {'pass': test_pass, 'fail': test_fail, 'skipped': no_test,
                'errors': self.illegal_actors, 'components': self.components} 
开发者ID:EricssonResearch,项目名称:calvin-base,代码行数:23,代码来源:test_actors.py

示例9: print_exc

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_traceback [as 别名]
def print_exc(limit=None, file=None):
    """Shorthand for 'print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback, limit, file)'.
    (In fact, it uses sys.exc_info() to retrieve the same information
    in a thread-safe way.)"""
    if file is None:
        file = sys.stderr
    try:
        etype, value, tb = sys.exc_info()
        print_exception(etype, value, tb, limit, file)
    finally:
        etype = value = tb = None 
开发者ID:glmcdona,项目名称:meddle,代码行数:13,代码来源:traceback.py

示例10: _query

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_traceback [as 别名]
def _query(self, path, before=None, after=None):
        url = '%s/lookup/%s' % (self.server, path)

        params = {}
        if self.limit:
            params['limit'] = self.limit
        if before and after:
            params['time_first_after'] = after
            params['time_last_before'] = before
        else:
            if before:
                params['time_first_before'] = before
            if after:
                params['time_last_after'] = after
        if params:
            url += '?{0}'.format(urllib.urlencode(params))

        req = urllib2.Request(url)
        req.add_header('Accept', 'application/json')
        req.add_header('X-Api-Key', self.apikey)
        try:
            http = urllib2.urlopen(req)
            while True:
                line = http.readline()
                if not line:
                    break
                yield json.loads(line)
        except (urllib2.HTTPError, urllib2.URLError), e:
            raise self.not_good, str(e), sys.exc_traceback


###method used for general term searches## 
开发者ID:kingtuna,项目名称:Hybrid-Darknet-Concept,代码行数:34,代码来源:daily_summary.py

示例11: _report_exception

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_traceback [as 别名]
def _report_exception(self):
        """Internal function."""
        import sys
        exc, val, tb = sys.exc_type, sys.exc_value, sys.exc_traceback
        root = self._root()
        root.report_callback_exception(exc, val, tb) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:8,代码来源:Tkinter.py


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