python类errorcode()的实例源码

err.py 文件源码 项目:nfcpy 作者: nfcpy 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __str__(self):
        return "nfc.llcp.Error: [{0}] {1}".format(
            errno.errorcode[self.errno], self.strerror)
err.py 文件源码 项目:nfcpy 作者: nfcpy 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __str__(self):
        return "nfc.llcp.ConnectRefused: [{0}] {1} with reason {2}".format(
            errno.errorcode[self.errno], self.strerror, self.reason)
pyinotify.py 文件源码 项目:ClassiPi 作者: mugroma3 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def str_errno(self):
        code = self.get_errno()
        if code is None:
            return 'Errno: no errno support'
        return 'Errno=%s (%s)' % (os.strerror(code), errno.errorcode[code])
pyinotify.py 文件源码 项目:isar 作者: ilbers 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def str_errno(self):
        code = self.get_errno()
        if code is None:
            return 'Errno: no errno support'
        return 'Errno=%s (%s)' % (os.strerror(code), errno.errorcode[code])
test_errno.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_using_errorcode(self):
        # Every key value in errno.errorcode should be on the module.
        for value in errno.errorcode.values():
            self.assertTrue(hasattr(errno, value),
                            'no %s attr in errno' % value)
test_errno.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_attributes_in_errorcode(self):
        for attribute in errno.__dict__.keys():
            if attribute.isupper():
                self.assertIn(getattr(errno, attribute), errno.errorcode,
                              'no %s attr in errno.errorcode' % attribute)
socks.py 文件源码 项目:microProxy 作者: mike820324 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def handle_stream_closed_error(self, error, event):
        if error.real_error:
            err_num = abs(error.real_error[0])
            try:
                errorcode = errno.errorcode[err_num]
            except KeyError:
                errorcode = "undefined(code={0})".format(err_num)

            logger.debug("connect to {0}:{1} with error code {2}".format(
                event.addr, event.port, errorcode))
            # NOTE: if we submit an incorrect address type,
            # the error code will be:
            # - ENOEXEC in macos.
            # - EBADF in linux.
            if err_num in (errno.ENOEXEC, errno.EBADF):
                reason = "ADDRESS_TYPE_NOT_SUPPORTED"
            elif err_num == errno.ETIMEDOUT:
                reason = "NETWORK_UNREACHABLE"
            else:
                logger.error("unhandled error code {0} received".format(errorcode))
                reason = "GENRAL_FAILURE"

            yield self.send_event_to_src_conn(Response(
                RESP_STATUS[reason],
                event.atyp, event.addr, event.port), raise_exception=False)
            raise DestNotConnectedError((event.addr, event.port))
        else:  # pragma: no cover
            # TODO: StreamClosedError without real_error?
            # need check that tornado would occur this situation?
            raise
test_errno.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def test_using_errorcode(self):
        # Every key value in errno.errorcode should be on the module.
        for value in errno.errorcode.itervalues():
            self.assertTrue(hasattr(errno, value), 'no %s attr in errno' % value)
test_errno.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 99 收藏 0 点赞 0 评论 0
def test_attributes_in_errorcode(self):
        for attribute in errno.__dict__.iterkeys():
            if attribute.isupper():
                self.assertIn(getattr(errno, attribute), errno.errorcode,
                              'no %s attr in errno.errorcode' % attribute)
test_errno.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_using_errorcode(self):
        # Every key value in errno.errorcode should be on the module.
        for value in errno.errorcode.itervalues():
            self.assertTrue(hasattr(errno, value), 'no %s attr in errno' % value)
test_errno.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def test_attributes_in_errorcode(self):
        for attribute in errno.__dict__.iterkeys():
            if attribute.isupper():
                self.assertIn(getattr(errno, attribute), errno.errorcode,
                              'no %s attr in errno.errorcode' % attribute)
test_tcp_internals.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _acceptFailureTest(self, socketErrorNumber):
        """
        Test behavior in the face of an exception from C{accept(2)}.

        On any exception which indicates the platform is unable or unwilling
        to allocate further resources to us, the existing port should remain
        listening, a message should be logged, and the exception should not
        propagate outward from doRead.

        @param socketErrorNumber: The errno to simulate from accept.
        """
        class FakeSocket(object):
            """
            Pretend to be a socket in an overloaded system.
            """
            def accept(self):
                raise socket.error(
                    socketErrorNumber, os.strerror(socketErrorNumber))

        factory = ServerFactory()
        port = self.port(0, factory, interface='127.0.0.1')
        originalSocket = port.socket
        try:
            port.socket = FakeSocket()

            port.doRead()

            expectedFormat = "Could not accept new connection (%s)"
            expectedErrorCode = errno.errorcode[socketErrorNumber]
            expectedMessage = expectedFormat % (expectedErrorCode,)
            for msg in self.messages:
                if msg.get('message') == (expectedMessage,):
                    break
            else:
                self.fail("Log event for failed accept not found in "
                          "%r" % (self.messages,))
        finally:
            port.socket = originalSocket
err.py 文件源码 项目:bitpay-brick 作者: javgh 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __str__(self):
        return "nfc.llcp.Error: [{0}] {1}".format(
            errno.errorcode[self.errno], self.strerror)
err.py 文件源码 项目:bitpay-brick 作者: javgh 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __str__(self):
        return "nfc.llcp.ConnectRefused: [{0}] {1} with reason {2}".format(
            errno.errorcode[self.errno], self.strerror, self.reason)
test_errno.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_using_errorcode(self):
        # Every key value in errno.errorcode should be on the module.
        for value in errno.errorcode.values():
            self.assertTrue(hasattr(errno, value),
                            'no %s attr in errno' % value)
test_errno.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_attributes_in_errorcode(self):
        for attribute in errno.__dict__.keys():
            if attribute.isupper():
                self.assertIn(getattr(errno, attribute), errno.errorcode,
                              'no %s attr in errno.errorcode' % attribute)
test_pep3151.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def test_errno_mapping(self):
        # The OSError constructor maps errnos to subclasses
        # A sample test for the basic functionality
        e = OSError(EEXIST, "Bad file descriptor")
        self.assertIs(type(e), FileExistsError)
        # Exhaustive testing
        for errcode, exc in self._map.items():
            e = OSError(errcode, "Some message")
            self.assertIs(type(e), exc)
        othercodes = set(errno.errorcode) - set(self._map)
        for errcode in othercodes:
            e = OSError(errcode, "Some message")
            self.assertIs(type(e), OSError)
evdev.py 文件源码 项目:FightstickDisplay 作者: calexil 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _IOR(type, nr, struct):
    request = _IOC(_IOC_READ, ord(type), nr, ctypes.sizeof(struct))
    def f(fileno):
        buffer = struct()
        if c.ioctl(fileno, request, ctypes.byref(buffer)) < 0:
            err = ctypes.c_int.in_dll(c, 'errno').value
            raise OSError(err, errno.errorcode[err])
        return buffer
    return f
evdev.py 文件源码 项目:FightstickDisplay 作者: calexil 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _IOR_len(type, nr):
    def f(fileno, buffer):
        request = _IOC(_IOC_READ, ord(type), nr, ctypes.sizeof(buffer))
        if c.ioctl(fileno, request, ctypes.byref(buffer)) < 0:
            err = ctypes.c_int.in_dll(c, 'errno').value
            raise OSError(err, errno.errorcode[err])
        return buffer
    return f
base.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def socket_connect(descriptor, address):
    """
    Attempts to connect to the address, returns the descriptor if it succeeds,
    returns None if it needs to trampoline, and raises any exceptions.
    """
    err = descriptor.connect_ex(address)
    if err in CONNECT_ERR:
        return None
    if err not in CONNECT_SUCCESS:
        raise socket.error(err, errno.errorcode[err])
    return descriptor


问题


面经


文章

微信
公众号

扫码关注公众号