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


Python errno.EIO属性代码示例

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


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

示例1: ccid_xfr_block

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EIO [as 别名]
def ccid_xfr_block(self, data, timeout=0.1):
        """Encapsulate host command *data* into an PC/SC Escape command to
        send to the device and extract the chip response if received
        within *timeout* seconds.

        """
        frame = struct.pack("<BI5B", 0x6F, len(data), 0, 0, 0, 0, 0) + data
        self.transport.write(bytearray(frame))
        frame = self.transport.read(int(timeout * 1000))
        if not frame or len(frame) < 10:
            log.error("insufficient data for decoding ccid response")
            raise IOError(errno.EIO, os.strerror(errno.EIO))
        if frame[0] != 0x80:
            log.error("expected a RDR_to_PC_DataBlock")
            raise IOError(errno.EIO, os.strerror(errno.EIO))
        if len(frame) != 10 + struct.unpack("<I", memoryview(frame)[1:5])[0]:
            log.error("RDR_to_PC_DataBlock length mismatch")
            raise IOError(errno.EIO, os.strerror(errno.EIO))
        return frame[10:] 
开发者ID:nfcpy,项目名称:nfcpy,代码行数:21,代码来源:acr122.py

示例2: command

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EIO [as 别名]
def command(self, cmd_code, cmd_data, timeout):
        """Send a host command and return the chip response.

        """
        log.log(logging.DEBUG-1, "{} {}".format(self.CMD[cmd_code],
                                                hexlify(cmd_data).decode()))

        frame = bytearray([0xD4, cmd_code]) + bytearray(cmd_data)
        frame = bytearray([0xFF, 0x00, 0x00, 0x00, len(frame)]) + frame

        frame = self.ccid_xfr_block(frame, timeout)
        if not frame or len(frame) < 4:
            log.error("insufficient data for decoding chip response")
            raise IOError(errno.EIO, os.strerror(errno.EIO))
        if not (frame[0] == 0xD5 and frame[1] == cmd_code + 1):
            log.error("received invalid chip response")
            raise IOError(errno.EIO, os.strerror(errno.EIO))
        if not (frame[-2] == 0x90 and frame[-1] == 0x00):
            log.error("received pseudo apdu with error status")
            raise IOError(errno.EIO, os.strerror(errno.EIO))
        return frame[2:-2] 
开发者ID:nfcpy,项目名称:nfcpy,代码行数:23,代码来源:acr122.py

示例3: read

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EIO [as 别名]
def read(self, timeout=0):
        if self.usb_inp is not None:
            try:
                ep_addr = self.usb_inp.getAddress()
                frame = self.usb_dev.bulkRead(ep_addr, 300, timeout)
            except libusb.USBErrorTimeout:
                raise IOError(errno.ETIMEDOUT, os.strerror(errno.ETIMEDOUT))
            except libusb.USBErrorNoDevice:
                raise IOError(errno.ENODEV, os.strerror(errno.ENODEV))
            except libusb.USBError as error:
                log.error("%r", error)
                raise IOError(errno.EIO, os.strerror(errno.EIO))

            if len(frame) == 0:
                log.error("bulk read returned zero data")
                raise IOError(errno.EIO, os.strerror(errno.EIO))

            frame = bytearray(frame)
            log.log(logging.DEBUG-1, "<<< %s", hexlify(frame).decode())
            return frame 
开发者ID:nfcpy,项目名称:nfcpy,代码行数:22,代码来源:transport.py

示例4: test_listen_dep_ioerror_exception_after_psl

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EIO [as 别名]
def test_listen_dep_ioerror_exception_after_psl(self, device):
        atr_req = 'D400 30313233343536373839 00000000'
        atr_res = 'D501 d0d1d2d3d4d5d6d7d8d9 0000000800'
        psl_req = 'D404 00 12 03'
        device.chipset.transport.read.side_effect = [
            ACK(), RSP('09 00'),                        # WriteRegister
            ACK(), RSP('8D 05 11' + atr_req),           # TgInitAsTarget
            ACK(), RSP('91 00'),                        # TgResponseToInitiator
            ACK(), RSP('89 00 06' + psl_req),           # TgGetInitiatorCommand
            ACK(), self.reg_rsp('FD'),                  # ReadRegister
            ACK(), RSP('09 00'),                        # WriteRegister
            ACK(), RSP('91 00'),                        # TgResponseToInitiator
            ACK(), self.reg_rsp('FD'),                  # ReadRegister
            ACK(), RSP('09 00'),                        # WriteRegister
            ACK(), IOError(errno.EIO, ""),              # TgGetInitiatorCommand
        ]
        target = nfc.clf.LocalTarget()
        target.sensf_res = HEX("01 01fe010203040506 0000000000000000 0000")
        target.sens_res = HEX("0101")
        target.sel_res = HEX("40")
        target.sdd_res = HEX("08010203")
        target.atr_res = HEX(atr_res)
        with pytest.raises(IOError):
            device.listen_dep(target, 1.0)
        assert device.chipset.transport.read.call_count == 20 
开发者ID:nfcpy,项目名称:nfcpy,代码行数:27,代码来源:base_clf_pn53x.py

示例5: test_listen_dep_not_atr_and_then_ioerror

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EIO [as 别名]
def test_listen_dep_not_atr_and_then_ioerror(self, device):
        atr_req = 'D4FF 30313233343536373839 00000000'
        atr_res = 'D501 d0d1d2d3d4d5d6d7d8d9 0000000800'
        device.chipset.transport.read.side_effect = [
            ACK(), RSP('09 00'),                        # WriteRegister
            ACK(), RSP('8D 05 11' + atr_req),           # TgInitAsTarget
            ACK(), IOError(errno.ETIMEDOUT, ""),        # TgInitAsTarget
            ACK(), IOError(errno.EIO, ""),              # TgInitAsTarget
        ]
        target = nfc.clf.LocalTarget()
        target.sensf_res = HEX("01 01fe010203040506 0000000000000000 0000")
        target.sens_res = HEX("0101")
        target.sel_res = HEX("40")
        target.sdd_res = HEX("08010203")
        target.atr_res = HEX(atr_res)
        with pytest.raises(IOError):
            device.listen_dep(target, 1.0)
        assert device.chipset.transport.read.call_count == 8 
开发者ID:nfcpy,项目名称:nfcpy,代码行数:20,代码来源:base_clf_pn53x.py

示例6: test_listen_dep_ioerror_exception_after_atr

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EIO [as 别名]
def test_listen_dep_ioerror_exception_after_atr(self, device):
        atr_req = 'D400 30313233343536373839 00000000'
        atr_res = 'D501 d0d1d2d3d4d5d6d7d8d9 0000000800'
        device.chipset.transport.read.side_effect = [
            ACK(), RSP('19'),                           # ResetMode
            ACK(), RSP('09 00'),                        # WriteRegister
            ACK(), RSP('33'),                           # RFConfiguration
            ACK(), RSP('13'),                           # SetParameters
            ACK(), RSP('09 00'),                        # WriteRegister
            ACK(), RSP('8D 05 11' + atr_req),           # TgInitAsTarget
            ACK(), RSP('93 00'),                        # TgSetGeneralBytes
            ACK(), IOError(errno.EIO, ""),              # TgGetInitiatorCommand
        ]
        target = nfc.clf.LocalTarget()
        target.sensf_res = HEX("01 01fe010203040506 0000000000000000 0000")
        target.sens_res = HEX("0101")
        target.sel_res = HEX("40")
        target.sdd_res = HEX("08010203")
        target.atr_res = HEX(atr_res)
        with pytest.raises(IOError):
            device.listen_dep(target, 1.0)
        assert device.chipset.transport.read.call_count == 16 
开发者ID:nfcpy,项目名称:nfcpy,代码行数:24,代码来源:test_clf_rcs956.py

示例7: test_listen_dep_not_atr_and_then_ioerror

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EIO [as 别名]
def test_listen_dep_not_atr_and_then_ioerror(self, device):
        atr_req = 'D4FF 30313233343536373839 00000000'
        atr_res = 'D501 d0d1d2d3d4d5d6d7d8d9 0000000800'
        device.chipset.transport.read.side_effect = [
            ACK(), RSP('19'),                           # ResetMode
            ACK(), RSP('09 00'),                        # WriteRegister
            ACK(), RSP('33'),                           # RFConfiguration
            ACK(), RSP('13'),                           # SetParameters
            ACK(), RSP('09 00'),                        # WriteRegister
            ACK(), RSP('8D 05 11' + atr_req),           # TgInitAsTarget
            ACK(), IOError(errno.ETIMEDOUT, ""),        # TgInitAsTarget
            ACK(), IOError(errno.EIO, ""),              # TgInitAsTarget
        ]
        target = nfc.clf.LocalTarget()
        target.sensf_res = HEX("01 01fe010203040506 0000000000000000 0000")
        target.sens_res = HEX("0101")
        target.sel_res = HEX("40")
        target.sdd_res = HEX("08010203")
        target.atr_res = HEX(atr_res)
        with pytest.raises(IOError):
            device.listen_dep(target, 1.0)
        assert device.chipset.transport.read.call_count == 16 
开发者ID:nfcpy,项目名称:nfcpy,代码行数:24,代码来源:test_clf_rcs956.py

示例8: readline

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EIO [as 别名]
def readline(self):
        """Read one line from the pseudoterminal, and return it as unicode.

        Can block if there is nothing to read. Raises :exc:`EOFError` if the
        terminal was closed.
        """
        try:
            s = self.fileobj.readline()
        except (OSError, IOError) as err:
            if err.args[0] == errno.EIO:
                # Linux-style EOF
                self.flag_eof = True
                raise EOFError('End Of File (EOF). Exception style platform.')
            raise
        if s == b'':
            # BSD-style EOF (also appears to work on recent Solaris (OpenIndiana))
            self.flag_eof = True
            raise EOFError('End Of File (EOF). Empty string style platform.')

        return s 
开发者ID:pypa,项目名称:pipenv,代码行数:22,代码来源:ptyprocess.py

示例9: read_nonblocking

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EIO [as 别名]
def read_nonblocking(self, size=1, timeout=None):
        """This reads data from the file descriptor.

        This is a simple implementation suitable for a regular file. Subclasses using ptys or pipes should override it.

        The timeout parameter is ignored.
        """

        try:
            s = os.read(self.child_fd, size)
        except OSError as err:
            if err.args[0] == errno.EIO:
                # Linux-style EOF
                self.flag_eof = True
                raise EOF('End Of File (EOF). Exception style platform.')
            raise
        if s == b'':
            # BSD-style EOF
            self.flag_eof = True
            raise EOF('End Of File (EOF). Empty string style platform.')

        s = self._decoder.decode(s, final=False)
        self._log(s, 'read')
        return s 
开发者ID:pypa,项目名称:pipenv,代码行数:26,代码来源:spawnbase.py

示例10: _read

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EIO [as 别名]
def _read(self, length=100):
        while 1:
            try:
                next = os.read(self._fd, length)
            except EnvironmentError as why:
                if self._restart and why.errno == EINTR:
                    continue
                elif why.errno == EIO:
                    raise EOFError("pty is closed")
                else:
                    raise
            else:
                break
        if self._log:
            self._log.write(next)
        return next 
开发者ID:kdart,项目名称:pycopia,代码行数:18,代码来源:proctools.py

示例11: set_tc_from_file

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EIO [as 别名]
def set_tc_from_file(logger, config_file_path, is_overwrite):
    return_code = 0

    loader = TcConfigLoader(logger)
    loader.is_overwrite = is_overwrite

    try:
        loader.load_tcconfig(config_file_path)
    except OSError as e:
        logger.error(msgfy.to_error_message(e))
        return errno.EIO

    for tcconfig_command in loader.get_tcconfig_commands():
        return_code |= spr.SubprocessRunner(tcconfig_command).run()

    return return_code 
开发者ID:thombashi,项目名称:tcconfig,代码行数:18,代码来源:_importer.py

示例12: on_message

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EIO [as 别名]
def on_message(self, client_message):
        if client_message.is_flag_set(BEGIN_END_FLAG):
            # handle message
            self._message_callback(client_message)
        elif client_message.is_flag_set(BEGIN_FLAG):
            self._incomplete_messages[client_message.get_correlation_id()] = client_message
        else:
            try:
                message = self._incomplete_messages[client_message.get_correlation_id()]
            except KeyError:
                raise socket.error(errno.EIO, "A message without the begin part is received.")
            message.accumulate(client_message)
            if client_message.is_flag_set(END_FLAG):
                message.add_flag(BEGIN_END_FLAG)
                self._message_callback(message)
                del self._incomplete_messages[client_message.get_correlation_id()] 
开发者ID:hazelcast,项目名称:hazelcast-python-client,代码行数:18,代码来源:client_message.py

示例13: test_lockReleasedDuringAcquireSymlink

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EIO [as 别名]
def test_lockReleasedDuringAcquireSymlink(self):
        """
        If the lock is released while an attempt is made to acquire
        it, the lock attempt fails and C{FilesystemLock.lock} returns
        C{False}.  This can happen on Windows when L{lockfile.symlink}
        fails with L{IOError} of C{EIO} because another process is in
        the middle of a call to L{os.rmdir} (implemented in terms of
        RemoveDirectory) which is not atomic.
        """
        def fakeSymlink(src, dst):
            # While another process id doing os.rmdir which the Windows
            # implementation of rmlink does, a rename call will fail with EIO.
            raise OSError(errno.EIO, None)

        self.patch(lockfile, 'symlink', fakeSymlink)

        lockf = self.mktemp()
        lock = lockfile.FilesystemLock(lockf)
        self.assertFalse(lock.lock())
        self.assertFalse(lock.locked) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:22,代码来源:test_lockfile.py

示例14: unlink

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EIO [as 别名]
def unlink(self, path):
        fn = "".join([self.root, path.lstrip("/")])
        try:
            self.fs.rm(fn, False)
        except (IOError, FileNotFoundError):
            raise FuseOSError(EIO) 
开发者ID:intake,项目名称:filesystem_spec,代码行数:8,代码来源:fuse.py

示例15: test_gaierror

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EIO [as 别名]
def test_gaierror(self):
        # Test that IOStream sets its exc_info on getaddrinfo error.
        # It's difficult to reliably trigger a getaddrinfo error;
        # some resolvers own't even return errors for malformed names,
        # so we mock it instead. If IOStream changes to call a Resolver
        # before sock.connect, the mock target will need to change too.
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
        stream = IOStream(s)
        stream.set_close_callback(self.stop)
        with mock.patch(
            "socket.socket.connect", side_effect=socket.gaierror(errno.EIO, "boom")
        ):
            with self.assertRaises(StreamClosedError):
                yield stream.connect(("localhost", 80))
            self.assertTrue(isinstance(stream.error, socket.gaierror)) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:17,代码来源:iostream_test.py


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