Ejemplo n.º 1
0
 def writeout(self):
     # Write to socket/server
     while True:
         try:
             (priority, sent, line) = self.output.get(True, 1)
         except Empty:
             if self.quitting:
                 break
             else:
                 continue
         try:
             while self.last + Config.getfloat("Connection", "antiflood") * (1 + (len(line) > 300) + (priority > 10)) >= time.time():
                 time.sleep(0.5)
             # Warn admins if the wait is too long
             if time.time() > sent + Config.getint("Connection", "maxdelay"):
                 if time.time() > self.wait_warned + 300:
                     self.wait_warned = time.time()
                     adminmsg("Message output message delay is too long: %.1f seconds" % (time.time() - sent))
             self.sock.send(encode(line) + CRLF)
             self.last = time.time()
             print "%s >>> %s" % (time.asctime(),encode(line),)
             self.output.task_done()
             if line[:4].upper() == "QUIT":
                 break
         except socket.error as exc:
             raise Reboot(exc)
Ejemplo n.º 2
0
 def writeout(self):
     # Write to socket/server
     while True:
         try:
             (priority, sent, line) = self.output.get(True, 1)
         except Empty:
             if self.quitting:
                 break
             else:
                 continue
         try:
             while self.last + Config.getfloat(
                     "Connection",
                     "antiflood") * (1 + (len(line) > 300) +
                                     (priority > 10)) >= time.time():
                 time.sleep(0.5)
             # Warn admins if the wait is too long
             if priority < 10 and time.time() > sent + Config.getint(
                     "Connection", "maxdelay"):
                 if time.time() > self.wait_warned + 300:
                     self.wait_warned = time.time()
                     admin_msg(
                         "Message output message delay is too long: %.1f seconds"
                         % (time.time() - sent))
             self.sock.send(encode(line) + CRLF)
             self.last = time.time()
             print "%s >> %s" % (
                 time.strftime("%Y%m%d %H:%M:%S |"),
                 encode(line),
             )
             self.output.task_done()
             if line[:4].upper() == "QUIT":
                 break
         except socket.error as exc:
             raise Reboot(exc)
Ejemplo n.º 3
0
 def write(self, line):
     # Write to socket/server
     try:
         ponging = self.pong.match(line)
         if ponging:
             self.sock.send(line + CRLF)
         else:
             while self.last + Config.getfloat("Connection",
                                               "antiflood") >= time.time():
                 time.sleep(0.5)
             self.sock.send(encode(line) + CRLF)
             self.last = time.time()
             print "%s >>> %s" % (
                 time.asctime(),
                 encode(line),
             )
     except socket.error as exc:
         raise Reboot(exc)