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