Exemplo n.º 1
0
 def datagramReceived(self, string, peer):
     try:
         metrics = collectd.parse_packet(string)
         if (len(metrics) > 0):
             self.recv_metrics(metrics)
     except:
         logger.exception()
Exemplo n.º 2
0
 def handle_delete(self, request, sender, cc):
     try:
         key = request["delete"]["key"]
         if (key is None):
             self.handle_delete_all(sender, cc)
         else:
             self.handle_delete_one(key, sender, cc)
     except:
         logger.exception()
         cc(500, {"reason": "internal server error"})
Exemplo n.º 3
0
 def connectionMade(self):
     try:
         self.redis = yield redis.ConnectionPool(self.cfg.get("redis", "host"),
                                                 self.cfg.getint("redis", "port"),
                                                 self.cfg.getint("redis", "db"),
                                                 True)
         self.pooling.start(5)
         xmppim.MessageProtocol.connectionMade(self)
     except:
         logger.exception()
Exemplo n.º 4
0
 def datagramReceived(self, string, peer):
     try:
         if (string == "ping\n" or string == "ping"):
             self.handle_ping(peer)
         else:
             self.handle_event(string)
     except ValueError:
         if (logger.level <= logger.DEBUG):
             logger.exception()
     except Exception, e:
         logger.warn("error receiving packet [peer: %s, %s]" % (repr(peer), e))
         if (logger.level <= logger.DEBUG):
             logger.exception()
Exemplo n.º 5
0
 def datagramReceived(self, string, peer):
     try:
         if (string == "ping\n" or string == "ping"):
             self.handle_ping(peer)
         else:
             self.handle_event(string)
     except ValueError:
         if (logger.level <= logger.DEBUG):
             logger.exception()
     except Exception, e:
         logger.warn("error receiving packet [peer: %s, %s]" %
                     (repr(peer), e))
         if (logger.level <= logger.DEBUG):
             logger.exception()
Exemplo n.º 6
0
 def recv_frame(self, frame):
     try:
         for l in frame.split(";"):
             c = l[:1]
             if (c == 'e'):
                 self.recv_event(parse_event(l + ";")[0])
             elif (c == 's'):
                 self.recv_status(parse_status(l + ";")[0])
             elif (c == 'c'):
                 parse_string(l, "close")
                 self.recv_close()
             elif (l != ""):
                 raise (RuntimeError())
     except:
         logger.error("bad frame: " + frame)
         logger.exception()
         self.transport.loseConnection()
Exemplo n.º 7
0
 def recv_frame(self, frame):
     try:
         for l in frame.split(";"):
             c = l[:1]
             if (c == 'e'):
                 self.recv_event(parse_event(l + ";")[0])
             elif (c == 's'):
                 self.recv_status(parse_status(l + ";")[0])
             elif (c == 'c'):
                 parse_string(l, "close")
                 self.recv_close()
             elif (l != ""):
                 raise(RuntimeError())
     except:
         logger.error("bad frame: " + frame)
         logger.exception()
         self.transport.loseConnection()
Exemplo n.º 8
0
 def handle_select(self, request, sender, cc):
     try:
         if ((request["select"]["regex"] == "leela.xmpp") and (request["select"]["proc"] == "*")):
             data0 = yield self.redis.hgetall("leela.xmpp")
             tmp   = []
             for (key, data1) in data0.iteritems():
                 data = parser.parse_json(data1)
                 sql  = pp.render_select(data["request"]["select"]["proc"],
                                         data["request"]["select"]["regex"])
                 if (data["sender"] == sender.userhost()):
                     tmp.append({"key": key,
                                 "cmd": sql
                                })
             cc(200, {"results": tmp})
         else:
             hcode = hashlib.sha512()
             hcode.update(sender.userhost())
             hcode.update(request["select"]["proc"])
             hcode.update(request["select"]["regex"])
             key   = hcode.hexdigest()
             self.redis.hsetnx("leela.xmpp", key, pp.render_json({"request": request, "sender": sender.userhost()}))
     except:
         logger.exception()
         cc(500, {"reason": "internal server error"})
Exemplo n.º 9
0
 def _attach(self, sock):
     try:
         databus.attach(self.cfg.get("storage", "multicast"), sock)
     except:
         logger.exception()
Exemplo n.º 10
0
 def _attach(self, sock):
     try:
         databus.attach(self.cfg.get("storage", "multicast"), sock)
     except:
         logger.exception()
Exemplo n.º 11
0
 def g(*args, **kwargs):
     try:
         f(*args, **kwargs)
     except:
         logger.exception()
Exemplo n.º 12
0
 def g(*args, **kwargs):
     try:
         f(*args, **kwargs)
     except:
         logger.exception()