Python errno.ESHUTDOWN Examples

The following are 30 code examples of errno.ESHUTDOWN(). 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: subprocessng.py    From NoobSec-Toolkit with GNU General Public License v2.0 6 votes vote down vote up
def _recv(self, which, maxsize):
            conn, maxsize = self.get_conn_maxsize(which, maxsize)
            if conn is None:
                return None

            try:
                x = msvcrt.get_osfhandle(conn.fileno())
                (read, nAvail, nMessage) = PeekNamedPipe(x, 0)
                if maxsize < nAvail:
                    nAvail = maxsize
                if nAvail > 0:
                    (errCode, read) = ReadFile(x, nAvail, None)
            except (ValueError, NameError):
                return self._close(which)
            except (subprocess.pywintypes.error, Exception), why:
                if why[0] in (109, errno.ESHUTDOWN):
                    return self._close(which)
                raise 
Example #2
Source File: async_sub.py    From fxxkpython with GNU General Public License v3.0 6 votes vote down vote up
def _recv(self, which, maxsize):
            conn, maxsize = self.get_conn_maxsize(which, maxsize)
            if conn is None:
                return None
            
            try:
                x = msvcrt.get_osfhandle(conn.fileno())
                (read, nAvail, nMessage) = PeekNamedPipe(x, 0)
                if maxsize < nAvail:
                    nAvail = maxsize
                if nAvail > 0:
                    (errCode, read) = ReadFile(x, nAvail, None)
            except ValueError:
                return self._close(which)
            except (subprocess.pywintypes.error, Exception):
                if geterror()[0] in (109, errno.ESHUTDOWN):
                    return self._close(which)
                raise
            
            if self.universal_newlines:
                # Translate newlines. For Python 3.x assume read is text.
                # If bytes then another solution is needed.
                read = read.replace("\r\n", "\n").replace("\r", "\n")
            return read 
Example #3
Source File: async_sub.py    From fxxkpython with GNU General Public License v3.0 6 votes vote down vote up
def _recv(self, which, maxsize):
            conn, maxsize = self.get_conn_maxsize(which, maxsize)
            if conn is None:
                return None
            
            try:
                x = msvcrt.get_osfhandle(conn.fileno())
                (read, nAvail, nMessage) = PeekNamedPipe(x, 0)
                if maxsize < nAvail:
                    nAvail = maxsize
                if nAvail > 0:
                    (errCode, read) = ReadFile(x, nAvail, None)
            except ValueError:
                return self._close(which)
            except (subprocess.pywintypes.error, Exception):
                if geterror()[0] in (109, errno.ESHUTDOWN):
                    return self._close(which)
                raise
            
            if self.universal_newlines:
                # Translate newlines. For Python 3.x assume read is text.
                # If bytes then another solution is needed.
                read = read.replace("\r\n", "\n").replace("\r", "\n")
            return read 
Example #4
Source File: async_sub.py    From fxxkpython with GNU General Public License v3.0 6 votes vote down vote up
def _recv(self, which, maxsize):
            conn, maxsize = self.get_conn_maxsize(which, maxsize)
            if conn is None:
                return None
            
            try:
                x = msvcrt.get_osfhandle(conn.fileno())
                (read, nAvail, nMessage) = PeekNamedPipe(x, 0)
                if maxsize < nAvail:
                    nAvail = maxsize
                if nAvail > 0:
                    (errCode, read) = ReadFile(x, nAvail, None)
            except ValueError:
                return self._close(which)
            except (subprocess.pywintypes.error, Exception):
                if geterror()[0] in (109, errno.ESHUTDOWN):
                    return self._close(which)
                raise
            
            if self.universal_newlines:
                # Translate newlines. For Python 3.x assume read is text.
                # If bytes then another solution is needed.
                read = read.replace("\r\n", "\n").replace("\r", "\n")
            return read 
Example #5
Source File: subprocess2.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def _recv(self, which, maxsize):
            conn, maxsize = self.get_conn_maxsize(which, maxsize)
            read = ""
            if conn is None:
                return None

            try:
                fd = conn.fileno()
                handle = get_osfhandle(fd)
                avail = c_ulong(0)
                PeekNamedPipe(handle, None, 0, None, byref(avail), None)
                nAvail = avail.value
                if maxsize < nAvail:
                    nAvail = maxsize
                if nAvail > 0:
                    read = os.read(fd, nAvail)
            except ValueError:
                return self._close(which)
            except (subprocess.pywintypes.error, Exception), why:
                if why[0] in (109, errno.ESHUTDOWN):
                    return self._close(which)
                raise 
Example #6
Source File: subprocessng.py    From EasY_HaCk with Apache License 2.0 6 votes vote down vote up
def _recv(self, which, maxsize):
            conn, maxsize = self.get_conn_maxsize(which, maxsize)
            if conn is None:
                return None

            try:
                x = msvcrt.get_osfhandle(conn.fileno())
                (read, nAvail, nMessage) = PeekNamedPipe(x, 0)
                if maxsize < nAvail:
                    nAvail = maxsize
                if nAvail > 0:
                    (errCode, read) = ReadFile(x, nAvail, None)
            except (ValueError, NameError):
                return self._close(which)
            except (subprocess.pywintypes.error, Exception), why:
                if why[0] in (109, errno.ESHUTDOWN):
                    return self._close(which)
                raise 
Example #7
Source File: TestCmd.py    From android-xmrig-miner with GNU General Public License v3.0 6 votes vote down vote up
def _recv(self, which, maxsize):
            conn, maxsize = self.get_conn_maxsize(which, maxsize)
            if conn is None:
                return None

            try:
                x = msvcrt.get_osfhandle(conn.fileno())
                (read, nAvail, nMessage) = PeekNamedPipe(x, 0)
                if maxsize < nAvail:
                    nAvail = maxsize
                if nAvail > 0:
                    (errCode, read) = ReadFile(x, nAvail, None)
            except ValueError:
                return self._close(which)
            except (subprocess.pywintypes.error, Exception), why:
                if why[0] in (109, errno.ESHUTDOWN):
                    return self._close(which)
                raise

            #if self.universal_newlines:
            #    read = self._translate_newlines(read) 
Example #8
Source File: subprocessng.py    From POC-EXP with GNU General Public License v3.0 6 votes vote down vote up
def _recv(self, which, maxsize):
            conn, maxsize = self.get_conn_maxsize(which, maxsize)
            if conn is None:
                return None

            try:
                x = msvcrt.get_osfhandle(conn.fileno())
                (read, nAvail, nMessage) = PeekNamedPipe(x, 0)
                if maxsize < nAvail:
                    nAvail = maxsize
                if nAvail > 0:
                    (errCode, read) = ReadFile(x, nAvail, None)
            except (ValueError, NameError):
                return self._close(which)
            except (subprocess.pywintypes.error, Exception), why:
                if why[0] in (109, errno.ESHUTDOWN):
                    return self._close(which)
                raise 
Example #9
Source File: TestCmd.py    From kawalpemilu2014 with GNU Affero General Public License v3.0 6 votes vote down vote up
def _recv(self, which, maxsize):
            conn, maxsize = self.get_conn_maxsize(which, maxsize)
            if conn is None:
                return None

            try:
                x = msvcrt.get_osfhandle(conn.fileno())
                (read, nAvail, nMessage) = PeekNamedPipe(x, 0)
                if maxsize < nAvail:
                    nAvail = maxsize
                if nAvail > 0:
                    (errCode, read) = ReadFile(x, nAvail, None)
            except ValueError:
                return self._close(which)
            except (subprocess.pywintypes.error, Exception), why:
                if why[0] in (109, errno.ESHUTDOWN):
                    return self._close(which)
                raise

            #if self.universal_newlines:
            #    read = self._translate_newlines(read) 
Example #10
Source File: TestCmd.py    From gyp with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def _recv(self, which, maxsize):
            conn, maxsize = self.get_conn_maxsize(which, maxsize)
            if conn is None:
                return None

            try:
                x = msvcrt.get_osfhandle(conn.fileno())
                (read, nAvail, nMessage) = PeekNamedPipe(x, 0)
                if maxsize < nAvail:
                    nAvail = maxsize
                if nAvail > 0:
                    (errCode, read) = ReadFile(x, nAvail, None)
            except ValueError:
                return self._close(which)
            except (subprocess.pywintypes.error, Exception) as why:
                if why[0] in (109, errno.ESHUTDOWN):
                    return self._close(which)
                raise

            #if self.universal_newlines:
            #    read = self._translate_newlines(read)
            return read 
Example #11
Source File: TestCmd.py    From gyp with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def _recv(self, which, maxsize):
            conn, maxsize = self.get_conn_maxsize(which, maxsize)
            if conn is None:
                return None

            try:
                x = msvcrt.get_osfhandle(conn.fileno())
                (read, nAvail, nMessage) = PeekNamedPipe(x, 0)
                if maxsize < nAvail:
                    nAvail = maxsize
                if nAvail > 0:
                    (errCode, read) = ReadFile(x, nAvail, None)
            except ValueError:
                return self._close(which)
            except (subprocess.pywintypes.error, Exception) as why:
                if why[0] in (109, errno.ESHUTDOWN):
                    return self._close(which)
                raise

            #if self.universal_newlines:
            #    read = self._translate_newlines(read)
            return read 
Example #12
Source File: subprocessng.py    From NoobSec-Toolkit with GNU General Public License v2.0 6 votes vote down vote up
def _recv(self, which, maxsize):
            conn, maxsize = self.get_conn_maxsize(which, maxsize)
            if conn is None:
                return None

            try:
                x = msvcrt.get_osfhandle(conn.fileno())
                (read, nAvail, nMessage) = PeekNamedPipe(x, 0)
                if maxsize < nAvail:
                    nAvail = maxsize
                if nAvail > 0:
                    (errCode, read) = ReadFile(x, nAvail, None)
            except (ValueError, NameError):
                return self._close(which)
            except (subprocess.pywintypes.error, Exception), why:
                if why[0] in (109, errno.ESHUTDOWN):
                    return self._close(which)
                raise 
Example #13
Source File: TestCmd.py    From GYP3 with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def _recv(self, which, maxsize):
            conn, maxsize = self.get_conn_maxsize(which, maxsize)
            if conn is None:
                return None

            try:
                x = msvcrt.get_osfhandle(conn.fileno())
                (read, nAvail, nMessage) = PeekNamedPipe(x, 0)
                if maxsize < nAvail:
                    nAvail = maxsize
                if nAvail > 0:
                    (errCode, read) = ReadFile(x, nAvail, None)
            except ValueError:
                return self._close(which)
            except (subprocess.pywintypes.error, Exception) as why:
                if why.args[0] in (109, errno.ESHUTDOWN):
                    return self._close(which)
                raise

            # if self.universal_newlines:
            #    read = self._translate_newlines(read)
            return read 
Example #14
Source File: TestCmd.py    From GYP3 with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def send(self, input):
            input = to_bytes(input)
            if not self.stdin:
                return None

            try:
                x = msvcrt.get_osfhandle(self.stdin.fileno())
                (errCode, written) = WriteFile(x, input)
            except ValueError:
                return self._close('stdin')
            except (subprocess.pywintypes.error, Exception) as why:
                if why.args[0] in (109, errno.ESHUTDOWN):
                    return self._close('stdin')
                raise

            return written 
Example #15
Source File: test_llcp_tco.py    From nfcpy with European Union Public License 1.1 6 votes vote down vote up
def test_recv(self, tco):
        pdu = nfc.llcp.pdu.UnnumberedInformation(1, 1, HEX('1122'))
        assert tco.enqueue(pdu) is True
        assert tco.recv() == pdu
        threading.Timer(0.01, tco.close).start()
        with pytest.raises(nfc.llcp.Error) as excinfo:
            tco.recv()
        assert excinfo.value.errno == errno.EPIPE
        with pytest.raises(nfc.llcp.Error) as excinfo:
            tco.recv()
        assert excinfo.value.errno == errno.ESHUTDOWN


# =============================================================================
# Logical Data Link
# ============================================================================= 
Example #16
Source File: tco.py    From nfcpy with European Union Public License 1.1 6 votes vote down vote up
def poll(self, event, timeout):
        if self.state.SHUTDOWN:
            raise err.Error(errno.ESHUTDOWN)

        if event == "recv":
            if self.state.ESTABLISHED or self.state.CLOSE_WAIT:
                rcvd_pdu = super(DataLinkConnection, self).poll(event, timeout)
                if self.state.ESTABLISHED or self.state.CLOSE_WAIT:
                    return isinstance(rcvd_pdu, pdu.Information)
        elif event == "send":
            if self.state.ESTABLISHED:
                if super(DataLinkConnection, self).poll(event, timeout):
                    return self.state.ESTABLISHED
                return False
        elif event == "acks":
            with self.acks_ready:
                if not self.acks_recvd > 0:
                    self.acks_ready.wait(timeout)
                if self.acks_recvd > 0:
                    self.acks_recvd = self.acks_recvd - 1
                    return True
                return False
        else:
            raise err.Error(errno.EINVAL) 
Example #17
Source File: tco.py    From nfcpy with European Union Public License 1.1 5 votes vote down vote up
def send(self, send_pdu, flags):
        if self.state.SHUTDOWN:
            raise err.Error(errno.ESHUTDOWN)
        log.debug("{0} send {1}".format(str(self), send_pdu))
        super(RawAccessPoint, self).send(send_pdu, flags)
        return self.state.ESTABLISHED is True 
Example #18
Source File: subprocessng.py    From POC-EXP with GNU General Public License v3.0 5 votes vote down vote up
def send(self, input):
            if not self.stdin:
                return None

            try:
                x = msvcrt.get_osfhandle(self.stdin.fileno())
                (errCode, written) = WriteFile(x, input)
            except ValueError:
                return self._close('stdin')
            except (subprocess.pywintypes.error, Exception), why:
                if why[0] in (109, errno.ESHUTDOWN):
                    return self._close('stdin')
                raise 
Example #19
Source File: tco.py    From nfcpy with European Union Public License 1.1 5 votes vote down vote up
def connect(self, dest):
        if self.state.SHUTDOWN:
            raise err.Error(errno.ESHUTDOWN)
        with self.lock:
            self.peer = dest
            return self.peer > 0 
Example #20
Source File: TestCmd.py    From android-xmrig-miner with GNU General Public License v3.0 5 votes vote down vote up
def send(self, input):
            if not self.stdin:
                return None

            try:
                x = msvcrt.get_osfhandle(self.stdin.fileno())
                (errCode, written) = WriteFile(x, input)
            except ValueError:
                return self._close('stdin')
            except (subprocess.pywintypes.error, Exception), why:
                if why[0] in (109, errno.ESHUTDOWN):
                    return self._close('stdin')
                raise 
Example #21
Source File: tco.py    From nfcpy with European Union Public License 1.1 5 votes vote down vote up
def getsockopt(self, option):
        if self.state.SHUTDOWN:
            raise err.Error(errno.ESHUTDOWN)
        return super(LogicalDataLink, self).getsockopt(option) 
Example #22
Source File: subprocessng.py    From EasY_HaCk with Apache License 2.0 5 votes vote down vote up
def send(self, input):
            if not self.stdin:
                return None

            try:
                x = msvcrt.get_osfhandle(self.stdin.fileno())
                (errCode, written) = WriteFile(x, input)
            except ValueError:
                return self._close('stdin')
            except (subprocess.pywintypes.error, Exception), why:
                if why[0] in (109, errno.ESHUTDOWN):
                    return self._close('stdin')
                raise 
Example #23
Source File: tco.py    From nfcpy with European Union Public License 1.1 5 votes vote down vote up
def recv(self):
        if self.state.SHUTDOWN:
            raise err.Error(errno.ESHUTDOWN)
        try:
            return super(RawAccessPoint, self).recv()
        except IndexError:
            raise err.Error(errno.EPIPE) 
Example #24
Source File: subprocess2.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def send(self, input):
            if not self.stdin:
                return None

            try:
                written = os.write(self.stdin, input)
            except ValueError:
                return self._close('stdin')
            except (subprocess.pywintypes.error, Exception), why:
                if why[0] in (109, errno.ESHUTDOWN):
                    return self._close('stdin')
                raise 
Example #25
Source File: TestCmd.py    From kawalpemilu2014 with GNU Affero General Public License v3.0 5 votes vote down vote up
def send(self, input):
            if not self.stdin:
                return None

            try:
                x = msvcrt.get_osfhandle(self.stdin.fileno())
                (errCode, written) = WriteFile(x, input)
            except ValueError:
                return self._close('stdin')
            except (subprocess.pywintypes.error, Exception), why:
                if why[0] in (109, errno.ESHUTDOWN):
                    return self._close('stdin')
                raise 
Example #26
Source File: async_sub.py    From fxxkpython with GNU General Public License v3.0 5 votes vote down vote up
def send(self, input):
            if not self.stdin:
                return None

            try:
                x = msvcrt.get_osfhandle(self.stdin.fileno())
                (errCode, written) = WriteFile(x, input)
            except ValueError:
                return self._close('stdin')
            except (subprocess.pywintypes.error, Exception):
                if geterror()[0] in (109, errno.ESHUTDOWN):
                    return self._close('stdin')
                raise

            return written 
Example #27
Source File: tco.py    From nfcpy with European Union Public License 1.1 5 votes vote down vote up
def poll(self, event, timeout):
        if self.state.SHUTDOWN:
            raise err.Error(errno.ESHUTDOWN)
        if event not in ("recv", "send"):
            raise err.Error(errno.EINVAL)
        return super(RawAccessPoint, self).poll(event, timeout) is not None 
Example #28
Source File: async_sub.py    From fxxkpython with GNU General Public License v3.0 5 votes vote down vote up
def send(self, input):
            if not self.stdin:
                return None

            try:
                x = msvcrt.get_osfhandle(self.stdin.fileno())
                (errCode, written) = WriteFile(x, input)
            except ValueError:
                return self._close('stdin')
            except (subprocess.pywintypes.error, Exception):
                if geterror()[0] in (109, errno.ESHUTDOWN):
                    return self._close('stdin')
                raise

            return written 
Example #29
Source File: tco.py    From nfcpy with European Union Public License 1.1 5 votes vote down vote up
def getsockopt(self, option):
        if self.state.SHUTDOWN:
            raise err.Error(errno.ESHUTDOWN)
        return super(RawAccessPoint, self).getsockopt(option) 
Example #30
Source File: async_sub.py    From fxxkpython with GNU General Public License v3.0 5 votes vote down vote up
def send(self, input):
            if not self.stdin:
                return None

            try:
                x = msvcrt.get_osfhandle(self.stdin.fileno())
                (errCode, written) = WriteFile(x, input)
            except ValueError:
                return self._close('stdin')
            except (subprocess.pywintypes.error, Exception):
                if geterror()[0] in (109, errno.ESHUTDOWN):
                    return self._close('stdin')
                raise

            return written