當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。