コード例 #1
0
ファイル: irc2you-server.py プロジェクト: stenbacka/irc2you
    def handle(self):
        while(True):
            log.debug("waiting for message")
            messageXML = self.rfile.readline()
            if(messageXML == ''):
                break
            log.debug("Message: " + messageXML)

            # Find username from unix socket
            pid, uid, gid = struct.unpack('3i', \
                    self.server.socket.getsockopt(socket.SOL_SOCKET, 17, \
                    struct.calcsize('3i')))
            username = pwd.getpwuid(uid).pw_name

            #log.debug("client: " + str(self.server.socket))
            log.debug("pid: " + str(pid) + " uid: " + str(uid) + " gid: " + str(gid))
            log.debug(pwd.getpwuid(uid))

            try:
                message = objectify.fromstring(messageXML, messageParser)

                conf = configManager.getConfig(username)
                if conf:
                    for n in conf.notifiers:
                        log.debug("Executing notifier")
                        n.execute(message)
            except etree.XMLSyntaxError as element:
                log.warn("Failed to parse message. Message: " + element.msg + \
                         ", XML: " + messageXML)
            log.debug("=====  This line has been intentionally left blank =====\n")
コード例 #2
0
ファイル: irc2you-server.py プロジェクト: stenbacka/irc2you
 def setup(self):
     log.debug("setting up socket")
     SocketServer.StreamRequestHandler.setup(self)
     self.messageQueue = Queue()
     t = Thread(target=self.message_sender)
     t.daemon = True
     t.start()
     pid, uid, gid = struct.unpack('3i', \
             self.server.socket.getsockopt(socket.SOL_SOCKET, 17, \
             struct.calcsize('3i')))
     username = pwd.getpwuid(uid).pw_name
     conf = configManager.getConfig(username)
     conf.messageQueue = self.messageQueue
     log.debug("done setting up socket")