Пример #1
0
 def on_open(self):
     try:
         token = verify_message(self.ws.handler.active_client.ws, ['inoffice', 'analytics'])
     except SocketException as e:
         logging.error(e)
         self.ws.handler.active_client.ws.send(json.dumps({'event':'invalid_access',  'data':e.json()}))
         return
     self.INFLUX = db.init_influxdb()
     self.MQ = db.init_mq()
     current = self.ws.handler.active_client
     current.token = token
     self.init_consumers()
Пример #2
0
 def on_open(self):
     try:
         token = verify_message(self.ws.handler.active_client.ws,
                                ['inoffice', 'analytics'])
     except SocketException as e:
         logging.error(e)
         self.ws.handler.active_client.ws.send(
             json.dumps({
                 'event': 'invalid_access',
                 'data': e.json()
             }))
         return
     self.INFLUX = db.init_influxdb()
     self.MQ = db.init_mq()
     current = self.ws.handler.active_client
     current.token = token
     self.init_consumers()
Пример #3
0
from celery import Celery
from celery import bootsteps
from kombu import Consumer
from lablog import config
from lablog import db
from lablog import messages
from lablog.models.client import Admin
from lablog.models.location import Location
from lablog.hooks import post_slack
from lablog.triggers import Trigger
import logging
import time

INFLUX = db.init_influxdb()
MQ = db.init_mq()
MQTT = db.init_mqtt()

app = Celery(__name__)
app.config_from_object('lablog.celeryconfig')

class TriggerConsumer(bootsteps.ConsumerStep):

    def __init__(self, *args, **kwargs):
        self.triggers = [a for a in Trigger.find()]
        super(TriggerConsumer, self).__init__(*args, **kwargs)

    def handle_trigger(self, body, msg):
        try:
            for t in self.triggers:
                if t.key == body['measurement']:
                    val = t._run(body)
Пример #4
0
from celery import Celery
from celery import bootsteps
from kombu import Consumer
from lablog import config
from lablog import db
from lablog import messages
from lablog.models.client import Admin
from lablog.models.location import Location
from lablog.hooks import post_slack
from lablog.triggers import Trigger
import logging

INFLUX = db.init_influxdb()
MQ = db.init_mq()

app = Celery(__name__)
app.config_from_object('lablog.celeryconfig')

class TriggerConsumer(bootsteps.ConsumerStep):

    def __init__(self, *args, **kwargs):
        self.triggers = [a for a in Trigger.find()]
        super(TriggerConsumer, self).__init__(*args, **kwargs)

    def handle_trigger(self, body, msg):
        try:
            for t in self.triggers:
                if t.key == body['measurement']:
                    val = t._run(body)
        except Exception as e:
            logging.exception(e)
Пример #5
0
 def init_dbs(self):
     g.ES = db.init_elasticsearch()
     g.INFLUX = db.init_influxdb()
     g.MONGO = db.init_mongodb()
     g.MQ = db.init_mq()
     humongolus.settings(logging, g.MONGO)