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


Python errno.ENETRESET属性代码示例

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


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

示例1: is_network_error

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENETRESET [as 别名]
def is_network_error(exception) -> bool:
    """
    :param exception: an exception error instance
    :return: True if exception detected as a network error, False otherwise
    """
    network_errors = [errno.ECONNABORTED, errno.ECONNREFUSED, errno.ENETRESET, errno.ECONNRESET,
                      errno.ENETUNREACH, errno.ENETDOWN]

    if isinstance(exception, HTTPError) or isinstance(exception, RequestException) or \
            hasattr(exception, 'errno') and exception.errno in network_errors:
        return True

    return False 
开发者ID:gnosis,项目名称:django-eth-events,代码行数:15,代码来源:utils.py

示例2: recv

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENETRESET [as 别名]
def recv(self, max_bytes):
        """
        Receive up to max_bytes data from the target.

        Args:
            max_bytes (int): Maximum number of bytes to receive.

        Returns:
            Received data.
        """
        try:
            # return self._client.read_eager()
            return self._client.read_until(b'>', timeout=self.timeout)  # TODO: Implementation Dependant

        except socket.timeout:
            self._active_session = False
            data = b''
            # raise exception.FuzzowskiTargetRecvTimeout()
        except socket.error as e:
            self._active_session = False
            if e.errno == errno.ECONNABORTED:
                # raise(exception.FuzzowskiTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror), None, sys.exc_info()[2])
                raise exception.FuzzowskiTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror)  # .with_traceback(sys.exc_info()[2])
            elif (e.errno == errno.ECONNRESET) or \
                    (e.errno == errno.ENETRESET) or \
                    (e.errno == errno.ETIMEDOUT):
                # raise(exception.FuzzowskiTargetConnectionReset, None, sys.exc_info()[2])
                raise exception.FuzzowskiTargetConnectionReset  # .with_traceback(sys.exc_info()[2])
            elif e.errno == errno.EWOULDBLOCK or e.errno == errno.EAGAIN:  # timeout condition if using SO_RCVTIMEO or SO_SNDTIMEO
                # raise exception.FuzzowskiTargetRecvTimeout()
                data = b''
            else:
                raise

        return data 
开发者ID:nccgroup,项目名称:fuzzowski,代码行数:37,代码来源:telnet_connection.py

示例3: send

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENETRESET [as 别名]
def send(self, data):
        """
        Send data to the target. Only valid after calling open!
        Some protocols will truncate; see self.MAX_PAYLOADS.

        Args:
            data: Data to send.

        Returns:
            int: Number of bytes actually sent.
        """
        # try:
        #     data = data[:self.MAX_PAYLOADS[self.proto]]
        # except KeyError:
        #     pass  # data = data

        try:
            self._client.write(data)
            num_sent = len(data)
        except socket.error as e:
            self._active_session = False
            if e.errno == errno.ECONNABORTED:
                raise(exception.FuzzowskiTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror),
                       None, sys.exc_info()[2])
            elif (e.errno == errno.ECONNRESET) or \
                    (e.errno == errno.ENETRESET) or \
                    (e.errno == errno.ETIMEDOUT) or \
                    (e.errno == errno.EPIPE):
                raise(exception.FuzzowskiTargetConnectionReset(None, sys.exc_info()[2]))
                # raise(exception.FuzzowskiTargetConnectionReset, None, sys.exc_info()[2])
            else:
                raise
        # TODO: OSError:
        except (Exception, OSError) as e:
            self._active_session = False
            raise(exception.FuzzowskiTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror),
                   None, sys.exc_info()[2])
        return num_sent 
开发者ID:nccgroup,项目名称:fuzzowski,代码行数:40,代码来源:telnet_connection.py

示例4: recv

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENETRESET [as 别名]
def recv(self, max_bytes):
        """
        Receives a packet from the raw socket. If max_bytes < packet_size, only the first max_bytes are returned and
        the rest of the packet is discarded. Otherwise, return the whole packet.

        Args:
            max_bytes (int): Maximum number of bytes to return. 0 to return the whole packet.

        Returns:
            Received data
        """
        data = b""

        try:
            data = self._sock.recv(self.packet_size)

            if 0 < max_bytes < self.packet_size:
                data = data[: self._packet_size]

        except socket.timeout:
            data = b""
        except socket.error as e:
            if e.errno == errno.ECONNABORTED:
                raise_(
                    exception.BoofuzzTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror),
                    None,
                    sys.exc_info()[2],
                )
            elif e.errno in [errno.ECONNRESET, errno.ENETRESET, errno.ETIMEDOUT]:
                raise_(exception.BoofuzzTargetConnectionReset(), None, sys.exc_info()[2])
            elif e.errno == errno.EWOULDBLOCK:
                data = b""
            else:
                raise

        return data 
开发者ID:jtpereyda,项目名称:boofuzz,代码行数:38,代码来源:raw_l3_socket_connection.py

示例5: send

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENETRESET [as 别名]
def send(self, data):
        """
        Send data to the target. Only valid after calling open!
        Data will be trunctated to self.packet_size (Default: 1500
        bytes).

        Args:
            data: Data to send.

        Returns:
            int: Number of bytes actually sent.
        """
        num_sent = 0

        data = data[: self.packet_size]

        try:
            num_sent = self._sock.sendto(data, (self.interface, self.ethernet_proto, 0, 0, self.l2_dst))

        except socket.error as e:
            if e.errno == errno.ECONNABORTED:
                raise_(
                    exception.BoofuzzTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror),
                    None,
                    sys.exc_info()[2],
                )
            elif e.errno in [errno.ECONNRESET, errno.ENETRESET, errno.ETIMEDOUT, errno.EPIPE]:
                raise_(exception.BoofuzzTargetConnectionReset(), None, sys.exc_info()[2])
            else:
                raise

        return num_sent 
开发者ID:jtpereyda,项目名称:boofuzz,代码行数:34,代码来源:raw_l3_socket_connection.py

示例6: recv

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENETRESET [as 别名]
def recv(self, max_bytes):
        """Receive up to max_bytes data from the target.

        Args:
            max_bytes(int): Maximum number of bytes to receive.

        Returns:
            Received data.
        """
        data = b""

        try:
            if self.bind or self.server:
                data, self._udp_client_port = self._sock.recvfrom(max_bytes)
            else:
                raise exception.SullyRuntimeError(
                    "UDPSocketConnection.recv() requires a bind address/port." " Current value: {}".format(self.bind)
                )
        except socket.timeout:
            data = b""
        except socket.error as e:
            if e.errno == errno.ECONNABORTED:
                raise_(
                    exception.BoofuzzTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror),
                    None,
                    sys.exc_info()[2],
                )
            elif e.errno in [errno.ECONNRESET, errno.ENETRESET, errno.ETIMEDOUT]:
                raise_(exception.BoofuzzTargetConnectionReset(), None, sys.exc_info()[2])
            elif e.errno == errno.EWOULDBLOCK:
                data = b""
            else:
                raise

        return data 
开发者ID:jtpereyda,项目名称:boofuzz,代码行数:37,代码来源:udp_socket_connection.py

示例7: send

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENETRESET [as 别名]
def send(self, data):
        """
        Send data to the target. Only valid after calling open!
        Some protocols will truncate; see self.MAX_PAYLOADS.

        Args:
            data: Data to send.

        Returns:
            int: Number of bytes actually sent.
        """
        num_sent = 0

        try:
            if self.server:
                if self._udp_client_port is None:
                    raise exception.BoofuzzError("recv() must be called before send with udp fuzzing servers.")

                num_sent = self._sock.sendto(data, self._udp_client_port)
            else:
                num_sent = self._sock.sendto(data, (self.host, self.port))
        except socket.error as e:
            if e.errno == errno.ECONNABORTED:
                raise_(
                    exception.BoofuzzTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror),
                    None,
                    sys.exc_info()[2],
                )
            elif e.errno in [errno.ECONNRESET, errno.ENETRESET, errno.ETIMEDOUT, errno.EPIPE]:
                raise_(exception.BoofuzzTargetConnectionReset(), None, sys.exc_info()[2])
            else:
                raise

        return num_sent 
开发者ID:jtpereyda,项目名称:boofuzz,代码行数:36,代码来源:udp_socket_connection.py

示例8: recv

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENETRESET [as 别名]
def recv(self, max_bytes):
        """
        Receives a packet from the raw socket. If max_bytes < mtu, only the first max_bytes are returned and
        the rest of the packet is discarded. Otherwise, return the whole packet.

        Args:
            max_bytes (int): Maximum number of bytes to return. 0 to return the whole packet.

        Returns:
            Received data
        """
        if self.ethernet_proto is None:
            raise Exception(
                "Receiving on Raw Layer 2 sockets is only supported if the socket "
                "is bound to an interface and protocol."
            )

        data = b""

        try:
            data = self._sock.recv(self.mtu)

            if 0 < len(data) < max_bytes:
                data = data[:max_bytes]
        except socket.timeout:
            data = b""
        except socket.error as e:
            if e.errno == errno.ECONNABORTED:
                raise_(
                    exception.BoofuzzTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror),
                    None,
                    sys.exc_info()[2],
                )
            elif e.errno in [errno.ECONNRESET, errno.ENETRESET, errno.ETIMEDOUT]:
                raise_(exception.BoofuzzTargetConnectionReset(), None, sys.exc_info()[2])
            elif e.errno == errno.EWOULDBLOCK:
                data = b""
            else:
                raise

        return data 
开发者ID:jtpereyda,项目名称:boofuzz,代码行数:43,代码来源:raw_l2_socket_connection.py

示例9: recv

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENETRESET [as 别名]
def recv(self, max_bytes):
        """
        Receive up to max_bytes data from the target.

        Args:
            max_bytes (int): Maximum number of bytes to receive.

        Returns:
            Received data.
        """
        data = b""

        try:
            data = self._sock.recv(max_bytes)
        except socket.timeout:
            data = b""
        except socket.error as e:
            if e.errno == errno.ECONNABORTED:
                raise_(
                    exception.BoofuzzTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror),
                    None,
                    sys.exc_info()[2],
                )
            elif (e.errno == errno.ECONNRESET) or (e.errno == errno.ENETRESET) or (e.errno == errno.ETIMEDOUT):
                raise_(exception.BoofuzzTargetConnectionReset(), None, sys.exc_info()[2])
            elif e.errno == errno.EWOULDBLOCK:  # timeout condition if using SO_RCVTIMEO or SO_SNDTIMEO
                data = b""
            else:
                raise

        return data 
开发者ID:jtpereyda,项目名称:boofuzz,代码行数:33,代码来源:tcp_socket_connection.py

示例10: send

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENETRESET [as 别名]
def send(self, data):
        """
        Send data to the target. Only valid after calling open!

        Args:
            data: Data to send.

        Returns:
            int: Number of bytes actually sent.
        """
        num_sent = 0

        try:
            num_sent = self._sock.send(data)
        except socket.error as e:
            if e.errno == errno.ECONNABORTED:
                raise_(
                    exception.BoofuzzTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror),
                    None,
                    sys.exc_info()[2],
                )
            elif e.errno in [errno.ECONNRESET, errno.ENETRESET, errno.ETIMEDOUT, errno.EPIPE]:
                raise_(exception.BoofuzzTargetConnectionReset(), None, sys.exc_info()[2])
            else:
                raise

        return num_sent 
开发者ID:jtpereyda,项目名称:boofuzz,代码行数:29,代码来源:tcp_socket_connection.py

示例11: recv

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENETRESET [as 别名]
def recv(self, max_bytes):
        """
        Receive up to max_bytes data from the target.

        Args:
            max_bytes (int): Maximum number of bytes to receive.

        Returns:
            Received data.
        """
        try:
            if self.proto in ['tcp', 'ssl']:
                data = self._sock.recv(max_bytes)
            elif self.proto == 'udp':
                # Not necessary to bind to a port to use this, right?
                # if self.bind:
                data, _ = self._sock.recvfrom(max_bytes)
                # else:
                #     raise exception.FuzzowskiRuntimeError(
                #         "SocketConnection.recv() for UDP requires a bind address/port."
                #         " Current value: {}".format(self.bind))
            elif self.proto in ['raw-l2', 'raw-l3']:
                # receive on raw is not supported. Since there is no specific protocol for raw, we would just have to
                # dump everything off the interface anyway, which is probably not what the user wants.
                data = b''
            else:
                raise exception.FuzzowskiRuntimeError("INVALID PROTOCOL SPECIFIED: %s" % self.proto)
        except socket.timeout:
            data = b''
            # raise exception.FuzzowskiTargetRecvTimeout()
        except socket.error as e:
            if e.errno == errno.ECONNABORTED:
                # raise(exception.FuzzowskiTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror), None, sys.exc_info()[2])
                raise exception.FuzzowskiTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror)  # .with_traceback(sys.exc_info()[2])
            elif (e.errno == errno.ECONNRESET) or \
                    (e.errno == errno.ENETRESET) or \
                    (e.errno == errno.ETIMEDOUT):
                # raise(exception.FuzzowskiTargetConnectionReset, None, sys.exc_info()[2])
                raise exception.FuzzowskiTargetConnectionReset  # .with_traceback(sys.exc_info()[2])
            elif e.errno == errno.EWOULDBLOCK or e.errno == errno.EAGAIN:  # timeout condition if using SO_RCVTIMEO or SO_SNDTIMEO
                # raise exception.FuzzowskiTargetRecvTimeout()
                data = b''
            else:
                raise

        return data 
开发者ID:nccgroup,项目名称:fuzzowski,代码行数:48,代码来源:socket_connection.py

示例12: send

# 需要导入模块: import errno [as 别名]
# 或者: from errno import ENETRESET [as 别名]
def send(self, data):
        """
        Send data to the target. Only valid after calling open!
        Some protocols will truncate; see self.MAX_PAYLOADS.

        Args:
            data: Data to send.

        Returns:
            int: Number of bytes actually sent.
        """
        try:
            data = data[:self.MAX_PAYLOADS[self.proto]]
        except KeyError:
            pass  # data = data

        try:
            if self.proto in ["tcp", "ssl"]:
                num_sent = self._sock.send(data)
            elif self.proto == "udp":
                num_sent = self._sock.sendto(data, (self.host, self.port))
            elif self.proto == "raw-l2":
                num_sent = self._sock.sendto(data, (self.host, 0))
            elif self.proto == "raw-l3":
                # Address tuple: (interface string,
                #                 Ethernet protocol number,
                #                 packet type (recv only),
                #                 hatype (recv only),
                #                 Ethernet address)
                # See man 7 packet for more details.
                num_sent = self._sock.sendto(data, (self.host, self.ethernet_proto, 0, 0, self.l2_dst))
            else:
                raise exception.FuzzowskiRuntimeError("INVALID PROTOCOL SPECIFIED: %s" % self.proto)
        except socket.error as e:
            if e.errno == errno.ECONNABORTED:
                raise(exception.FuzzowskiTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror),
                       None, sys.exc_info()[2])
            elif (e.errno == errno.ECONNRESET) or \
                    (e.errno == errno.ENETRESET) or \
                    (e.errno == errno.ETIMEDOUT) or \
                    (e.errno == errno.EPIPE):
                raise(exception.FuzzowskiTargetConnectionReset(None, sys.exc_info()[2]))
                # raise(exception.FuzzowskiTargetConnectionReset, None, sys.exc_info()[2])
            else:
                raise
        # TODO: OSError:
        except (Exception, OSError) as e:
            raise(exception.FuzzowskiTargetConnectionAborted(socket_errno=e.errno, socket_errmsg=e.strerror),
                   None, sys.exc_info()[2])
        return num_sent 
开发者ID:nccgroup,项目名称:fuzzowski,代码行数:52,代码来源:socket_connection.py


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