Python errno.EIO Examples
The following are 30
code examples of errno.EIO().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
errno
, or try the search function
.
Example #1
Source File: ptyprocess.py From pipenv with MIT License | 6 votes |
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
Example #2
Source File: base_clf_pn53x.py From nfcpy with European Union Public License 1.1 | 6 votes |
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
Example #3
Source File: base_clf_pn53x.py From nfcpy with European Union Public License 1.1 | 6 votes |
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
Example #4
Source File: test_clf_rcs956.py From nfcpy with European Union Public License 1.1 | 6 votes |
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
Example #5
Source File: _importer.py From tcconfig with MIT License | 6 votes |
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
Example #6
Source File: test_clf_rcs956.py From nfcpy with European Union Public License 1.1 | 6 votes |
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
Example #7
Source File: ptyprocess.py From pipenv-sublime with MIT License | 6 votes |
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
Example #8
Source File: spawnbase.py From pipenv-sublime with MIT License | 6 votes |
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
Example #9
Source File: client_message.py From hazelcast-python-client with Apache License 2.0 | 6 votes |
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()]
Example #10
Source File: transport.py From nfcpy with European Union Public License 1.1 | 6 votes |
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
Example #11
Source File: acr122.py From nfcpy with European Union Public License 1.1 | 6 votes |
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]
Example #12
Source File: acr122.py From nfcpy with European Union Public License 1.1 | 6 votes |
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:]
Example #13
Source File: ptyprocess.py From sublime_debugger with MIT License | 6 votes |
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
Example #14
Source File: spawnbase.py From pipenv with MIT License | 6 votes |
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
Example #15
Source File: test_lockfile.py From python-for-android with Apache License 2.0 | 6 votes |
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)
Example #16
Source File: proctools.py From pycopia with Apache License 2.0 | 6 votes |
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
Example #17
Source File: unix_events.py From annotated-py-projects with MIT License | 5 votes |
def _fatal_error(self, exc, message='Fatal error on pipe transport'): # should be called by exception handler only if (isinstance(exc, OSError) and exc.errno == errno.EIO): if self._loop.get_debug(): logger.debug("%r: %s", self, message, exc_info=True) else: self._loop.call_exception_handler({ 'message': message, 'exception': exc, 'transport': self, 'protocol': self._protocol, }) self._close(exc)
Example #18
Source File: aioutils.py From aionotify with BSD 2-Clause "Simplified" License | 5 votes |
def _fatal_error(self, exc, message): if isinstance(exc, OSError) and exc.errno == errno.EIO: if self._loop.get_debug(): logger.debug("%r: %s", self, message, exc_info=True) else: self._loop.call_exception_handler({ 'message': message, 'exception': exc, 'transport': self, 'protocol': self._protocol, }) self._close(error=exc)
Example #19
Source File: _async.py From pipenv-sublime with MIT License | 5 votes |
def connection_lost(self, exc): if isinstance(exc, OSError) and exc.errno == errno.EIO: # We may get here without eof_received being called, e.g on Linux self.eof_received() elif exc is not None: self.error(exc)
Example #20
Source File: zap_common.py From openshift-tools with Apache License 2.0 | 5 votes |
def wait_for_zap_start(zap, timeout): version = None for x in range(0, timeout): try: version = zap.core.version logging.debug('ZAP Version ' + version) logging.debug('Took ' + str(x) + ' seconds') break except IOError: time.sleep(1) if not version: raise IOError( errno.EIO, 'Failed to connect to ZAP after {0} seconds'.format(timeout))
Example #21
Source File: ptyprocess.py From pipenv-sublime with MIT License | 5 votes |
def read(self, size=1024): """Read and return at most ``size`` bytes from the pty. Can block if there is nothing to read. Raises :exc:`EOFError` if the terminal was closed. Unlike Pexpect's ``read_nonblocking`` method, this doesn't try to deal with the vagaries of EOF on platforms that do strange things, like IRIX or older Solaris systems. It handles the errno=EIO pattern used on Linux, and the empty-string return used on BSD platforms and (seemingly) on recent Solaris. """ try: s = self.fileobj.read1(size) 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
Example #22
Source File: __init__.py From camr with GNU General Public License v2.0 | 5 votes |
def __interact_copy(self, escape_character=None, input_filter=None, output_filter=None): '''This is used by the interact() method. ''' while self.isalive(): r, w, e = self.__select([self.child_fd, self.STDIN_FILENO], [], []) if self.child_fd in r: try: data = self.__interact_read(self.child_fd) except OSError as err: if err.args[0] == errno.EIO: # Linux-style EOF break raise if data == b'': # BSD-style EOF break if output_filter: data = output_filter(data) if self.logfile is not None: self.logfile.write(data) self.logfile.flush() os.write(self.STDOUT_FILENO, data) if self.STDIN_FILENO in r: data = self.__interact_read(self.STDIN_FILENO) if input_filter: data = input_filter(data) i = data.rfind(escape_character) if i != -1: data = data[:i] self.__interact_writen(self.child_fd, data) break self.__interact_writen(self.child_fd, data)
Example #23
Source File: test_lockfile.py From learn_python3_spider with MIT License | 5 votes |
def test_symlinkErrorPOSIX(self): """ An L{OSError} raised by C{symlink} on a POSIX platform with an errno of C{EACCES} or C{EIO} is passed to the caller of L{FilesystemLock.lock}. On POSIX, unlike on Windows, these are unexpected errors which cannot be handled by L{FilesystemLock}. """ self._symlinkErrorTest(errno.EACCES) self._symlinkErrorTest(errno.EIO)
Example #24
Source File: test_lockfile.py From learn_python3_spider with MIT License | 5 votes |
def test_symlinkEIOWindows(self): """ L{lockfile.symlink} raises L{OSError} with C{errno} set to L{EIO} when the underlying L{rename} call fails with L{EIO}. Renaming a file on Windows may fail if the target of the rename is in the process of being deleted (directory deletion appears not to be atomic). """ name = self.mktemp() def fakeRename(src, dst): raise IOError(errno.EIO, None) self.patch(lockfile, 'rename', fakeRename) exc = self.assertRaises(IOError, lockfile.symlink, name, "foo") self.assertEqual(exc.errno, errno.EIO)
Example #25
Source File: lockfile.py From learn_python3_spider with MIT License | 5 votes |
def readlink(filename): """ Read the contents of C{filename}. See the above comment block as to why this is needed. """ try: fObj = _open(os.path.join(filename, 'symlink'), 'r') except IOError as e: if e.errno == errno.ENOENT or e.errno == errno.EIO: raise OSError(e.errno, None) raise else: with fObj: result = fObj.read() return result
Example #26
Source File: test_pidfile.py From learn_python3_spider with MIT License | 5 votes |
def test_readOpenRaisesOSErrorNotENOENT(self): """ L{PIDFile.read} re-raises L{OSError} if the associated C{errno} is anything other than L{errno.ENOENT}. """ def oops(mode="r"): raise OSError(errno.EIO, "I/O error") self.patch(DummyFilePath, "open", oops) pidFile = PIDFile(DummyFilePath()) error = self.assertRaises(OSError, pidFile.read) self.assertEqual(error.errno, errno.EIO)
Example #27
Source File: unix_events.py From Imogen with MIT License | 5 votes |
def _fatal_error(self, exc, message='Fatal error on pipe transport'): # should be called by exception handler only if (isinstance(exc, OSError) and exc.errno == errno.EIO): if self._loop.get_debug(): logger.debug("%r: %s", self, message, exc_info=True) else: self._loop.call_exception_handler({ 'message': message, 'exception': exc, 'transport': self, 'protocol': self._protocol, }) self._close(exc)
Example #28
Source File: netutil_test.py From pySINDy with MIT License | 5 votes |
def _failing_getaddrinfo(*args): """Dummy implementation of getaddrinfo for use in mocks""" raise socket.gaierror(errno.EIO, "mock: lookup failed")
Example #29
Source File: iostream_test.py From pySINDy with MIT License | 5 votes |
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))
Example #30
Source File: unix_events.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def _fatal_error(self, exc, message='Fatal error on pipe transport'): # should be called by exception handler only if (isinstance(exc, OSError) and exc.errno == errno.EIO): if self._loop.get_debug(): logger.debug("%r: %s", self, message, exc_info=True) else: self._loop.call_exception_handler({ 'message': message, 'exception': exc, 'transport': self, 'protocol': self._protocol, }) self._close(exc)