コード例 #1
0
    def __init__(self, simplemonitor, port, key=None):
        """Set up the thread.

        simplemonitor is a SimpleMonitor object which we will put our results into.
        """
        if key is None or key == "":
            raise util.LoggerConfigurationError("Network logger key is missing")
        Thread.__init__(self)
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.sock.bind(('', port))
        self.simplemonitor = simplemonitor
        self.key = bytearray(key, 'utf-8')
        self.logger = logging.getLogger('simplemonitor.logger.networklistener')
        self.running = False
コード例 #2
0
    def __init__(self, simplemonitor, port, key=None, allow_pickle=True):
        """Set up the thread.

        simplemonitor is a SimpleMonitor object which we will put our results into.
        """
        if key is None or key == "":
            raise util.LoggerConfigurationError("Network logger key is missing")
        Thread.__init__(self)
        self.allow_pickle = allow_pickle
        # try IPv6 and fallback to IPv4
        try:
            self.sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
            self.sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, False)
        except OSError:
            self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.sock.bind(('', port))
        self.simplemonitor = simplemonitor
        self.key = bytearray(key, 'utf-8')
        self.logger = logging.getLogger('simplemonitor.logger.networklistener')
        self.running = False