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


Python sys.exc_clear方法代码示例

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


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

示例1: iMain

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_clear [as 别名]
def iMain():
    iRetval = 0
    oOm = None
    try:
        oOm = oOmain(sys.argv[1:])
    except KeyboardInterrupt:
        pass
    except Exception as e:
        sys.stderr.write("ERROR: " +str(e) +"\n" + \
                         traceback.format_exc(10) +"\n")
        sys.stderr.flush()
        sys.exc_clear()
        iRetval = 1
    finally:
        if oOm: oOm.vClose()
    return iRetval 
开发者ID:OpenTrading,项目名称:OpenTrader,代码行数:18,代码来源:OTBackTest.py

示例2: test_clear_nested_func

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_clear [as 别名]
def test_clear_nested_func(self):
        def f():
            try:
                self.A(13)
                raise ValueError(54)
            except:
                self.A(54)
                sys.exc_clear()
                self.A(None)
            self.A(None)  # will be restored after func returns
        #
        try:
            raise ValueError(13)
        except:
            self.A(13)
            f()  # calls sys.exc_clear()
            self.A(13)  # still restored even after clear
        self.A(13)


    # Test clearing when there isn't an active exception (outside except block) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:23,代码来源:test_excinfo.py

示例3: test_clear_no_active_ex

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_clear [as 别名]
def test_clear_no_active_ex(self):
        self.A(None)
        sys.exc_clear()
        self.A(None)
        try:
            sys.exc_clear()
            self.A(None)
        except:
            pass
        try:
            pass
        finally:
            sys.exc_clear()
            self.A(None)
        self.A(None)

    #========================================================
    # With's Pep (http://www.python.org/dev/peps/pep-0343/) says the
    # __exit__ can be invoked by an except block,
    # but unlike a normal except, that shouldn't set sys.exc_info(). 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_excinfo.py

示例4: _edit_db_string

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_clear [as 别名]
def _edit_db_string( self,preset,type,label ):
        keyboard = xbmc.Keyboard(preset)
        keyboard.doModal()
        if (keyboard.isConfirmed()):
            try:
                InputLabel=keyboard.getText()
                conv=time.strptime(InputLabel,"%d/%m/%Y")
              #  InputLabel = Time.strftime('%Y-%m-%d')
                InputLabel = time.strftime("%Y-%m-%d",conv)
            except Exception:
                sys.exc_clear()
            if ((type == "Song") or (type == "Album") or (type == "Artist")):
                xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id": 1, "method": "AudioLibrary.Set%sDetails", "params": { "%s": "%s", "%sid":%s }}' % (type,label,InputLabel,type.lower(),self.DBID))
            else:
                xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id": 1, "method": "VideoLibrary.Set%sDetails", "params": { "%s": "%s", "%sid":%s }}' % (type,label,InputLabel,type.lower(),self.DBID))
        else:
            return "" 
开发者ID:Guilouz,项目名称:repository.guilouz,代码行数:19,代码来源:default.py

示例5: test_failureStructurePreserved

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_clear [as 别名]
def test_failureStructurePreserved(self):
        """
        Round-tripping a failure through L{eventAsJSON} preserves its class and
        structure.
        """
        events = []
        log = Logger(observer=events.append)
        try:
            1 / 0
        except ZeroDivisionError:
            f = Failure()
            log.failure("a message about failure", f)
        import sys
        if sys.exc_info()[0] is not None:
            # Make sure we don't get the same Failure by accident.
            sys.exc_clear()
        self.assertEqual(len(events), 1)
        loaded = eventFromJSON(self.savedEventJSON(events[0]))['log_failure']
        self.assertIsInstance(loaded, Failure)
        self.assertTrue(loaded.check(ZeroDivisionError))
        self.assertIsInstance(loaded.getTraceback(), str) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:23,代码来源:test_json.py

示例6: handle

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_clear [as 别名]
def handle(self, conn, address):
        """
        Interact with one remote user.

        .. versionchanged:: 1.1b2 Each connection gets its own
            ``locals`` dictionary. Previously they were shared in a
            potentially unsafe manner.
        """
        fobj = conn.makefile(mode="rw")
        fobj = _fileobject(conn, fobj, self.stderr)
        getcurrent()._fileobj = fobj

        getcurrent().switch_in()
        try:
            console = InteractiveConsole(self._create_interactive_locals())
            console.interact(banner=self.banner)
        except SystemExit:  # raised by quit()
            if hasattr(sys, 'exc_clear'): # py2
                sys.exc_clear()
        finally:
            conn.close()
            fobj.close() 
开发者ID:leancloud,项目名称:satori,代码行数:24,代码来源:backdoor.py

示例7: nb_read

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_clear [as 别名]
def nb_read(fd, n):
        """Read up to `n` bytes from file descriptor `fd`. Return a string
        containing the bytes read. If end-of-file is reached, an empty string
        is returned.

        The descriptor must be in non-blocking mode.
        """
        hub, event = None, None
        while True:
            try:
                return _read(fd, n)
            except OSError as e:
                if e.errno not in ignored_errors:
                    raise
                if not PY3:
                    sys.exc_clear()
            if hub is None:
                hub = get_hub()
                event = hub.loop.io(fd, 1)
            hub.wait(event) 
开发者ID:leancloud,项目名称:satori,代码行数:22,代码来源:os.py

示例8: nb_write

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_clear [as 别名]
def nb_write(fd, buf):
        """Write bytes from buffer `buf` to file descriptor `fd`. Return the
        number of bytes written.

        The file descriptor must be in non-blocking mode.
        """
        hub, event = None, None
        while True:
            try:
                return _write(fd, buf)
            except OSError as e:
                if e.errno not in ignored_errors:
                    raise
                if not PY3:
                    sys.exc_clear()
            if hub is None:
                hub = get_hub()
                event = hub.loop.io(fd, 2)
            hub.wait(event) 
开发者ID:leancloud,项目名称:satori,代码行数:21,代码来源:os.py

示例9: write

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_clear [as 别名]
def write(self, data):
        """Write DATA to the underlying SSL channel.  Returns
        number of bytes of DATA actually transmitted."""
        while True:
            try:
                return self._sslobj.write(data)
            except SSLError as ex:
                if ex.args[0] == SSL_ERROR_WANT_READ:
                    if self.timeout == 0.0:
                        raise
                    sys.exc_clear()
                    self._wait(self._read_event, timeout_exc=_SSLErrorWriteTimeout)
                elif ex.args[0] == SSL_ERROR_WANT_WRITE:
                    if self.timeout == 0.0:
                        raise
                    sys.exc_clear()
                    self._wait(self._write_event, timeout_exc=_SSLErrorWriteTimeout)
                else:
                    raise 
开发者ID:leancloud,项目名称:satori,代码行数:21,代码来源:_ssl2.py

示例10: _sslobj_shutdown

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_clear [as 别名]
def _sslobj_shutdown(self):
        while True:
            try:
                return self._sslobj.shutdown()
            except SSLError as ex:
                if ex.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
                    return ''
                elif ex.args[0] == SSL_ERROR_WANT_READ:
                    if self.timeout == 0.0:
                        raise
                    sys.exc_clear()
                    self._wait(self._read_event, timeout_exc=_SSLErrorReadTimeout)
                elif ex.args[0] == SSL_ERROR_WANT_WRITE:
                    if self.timeout == 0.0:
                        raise
                    sys.exc_clear()
                    self._wait(self._write_event, timeout_exc=_SSLErrorWriteTimeout)
                else:
                    raise 
开发者ID:leancloud,项目名称:satori,代码行数:21,代码来源:_ssl2.py

示例11: do_handshake

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_clear [as 别名]
def do_handshake(self):
        """Perform a TLS/SSL handshake."""
        while True:
            try:
                return self._sslobj.do_handshake()
            except SSLError as ex:
                if ex.args[0] == SSL_ERROR_WANT_READ:
                    if self.timeout == 0.0:
                        raise
                    sys.exc_clear()
                    self._wait(self._read_event, timeout_exc=_SSLErrorHandshakeTimeout)
                elif ex.args[0] == SSL_ERROR_WANT_WRITE:
                    if self.timeout == 0.0:
                        raise
                    sys.exc_clear()
                    self._wait(self._write_event, timeout_exc=_SSLErrorHandshakeTimeout)
                else:
                    raise 
开发者ID:leancloud,项目名称:satori,代码行数:20,代码来源:_ssl2.py

示例12: test_tback_no_trace_from_py_file

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_clear [as 别名]
def test_tback_no_trace_from_py_file(self):
        try:
            t = self._file_template("runtimeerr.html")
            t.render()
        except:
            t, v, tback = sys.exc_info()

        if not compat.py3k:
            # blow away tracebaack info
            sys.exc_clear()

        # and don't even send what we have.
        html_error = exceptions.html_error_template().render_unicode(
            error=v, traceback=None
        )
        assert (
            "local variable 'y' referenced before assignment"
            in html_error
        ) 
开发者ID:sqlalchemy,项目名称:mako,代码行数:21,代码来源:test_exceptions.py

示例13: vPyDeInit

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_clear [as 别名]
def vPyDeInit():
    global oTKINTER_ROOT, sSTDOUT_FD
    if sSTDOUT_FD:
        try:
            sys.stdout = sys.__stdout__
            sys.stderr = sys.__stderr__
            sName = sSTDOUT_FD.name
            # sShowInfo('vPyDeInit', "Closing %s" % (sName,))
            sSTDOUT_FD.write('INFO : vPyDeInit ' + "Closing outfile %s\n" % (sName,))
            # oLOG.shutdown()
            sSTDOUT_FD.flush()
            sSTDOUT_FD.close()
            sSTDOUT_FD = None
        except Exception as e:
            # You probably have not stdout so no point in logging it!
            print "Error closing %s\n%s" % (sSTDOUT_FD, str(e),)
            sys.exc_clear()

    if oTKINTER_ROOT:
        oTKINTER_ROOT.destroy()
        oTKINTER_ROOT = None

    sys.exc_clear() 
开发者ID:OpenTrading,项目名称:OTMql4AMQP,代码行数:25,代码来源:__init__.py

示例14: vPikaCallbackOnListener

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_clear [as 别名]
def vPikaCallbackOnListener(self, oChannel, oMethod, oProperties, sBody):
        assert sBody, "vPikaCallbackOnListener: no sBody received"
        oChannel.basic_ack(delivery_tag=oMethod.delivery_tag)
        sMess = "vPikaCallbackOnListener Listened: %r" % sBody
        sys.stdout.write("INFO: " +sMess +"\n")
        sys.stdout.flush()
        # we will assume that the sBody
        # is a "|" seperated list of command and arguments
        # FixMe: the sMess must be in the right format
        # FixMe: refactor for multiple charts:
        # we must push to the right chart
        try:
            self.vPikaDispatchOnListener(sBody, oProperties)
        except Exception as e:
            sys.stdout.write("ERROR: " +str(e) +"\n" + \
                             traceback.format_exc(10) +"\n")
            sys.stdout.flush()
            sys.exc_clear()

    # unused 
开发者ID:OpenTrading,项目名称:OTMql4AMQP,代码行数:22,代码来源:PikaChart.py

示例15: put_dynamo_main

# 需要导入模块: import sys [as 别名]
# 或者: from sys import exc_clear [as 别名]
def put_dynamo_main(dynamo_object):
    print("put_dynamo to table: " + str(DYNAMO_MAIN))
    print("dynamo_object: {}".format(dynamo_object))    
    table = dynamodb.Table(DYNAMO_MAIN)
    try:
        response = table.put_item(
            Item=dynamo_object,
            ConditionExpression='attribute_not_exists(id_filename)'
        )
        print("dynamo put_item succeeded: {}".format(response))
    except Exception as e:
        # Ignore the ConditionalCheckFailedException, bubble up other exceptions.
        print("pizzaninja: {}".format(e)) 
        print('broken dynamo: {}'.format(dynamo_object))
        if e.response['Error']['Code'] != 'ConditionalCheckFailedException':
            raise e
        sys.exc_clear() 
开发者ID:aws-samples,项目名称:aws-elemental-instant-video-highlights,代码行数:19,代码来源:lambda_function.py


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