Esempio n. 1
0
def main():
    conn_settings = Connector_Settings(sys.argv[1], sys.argv[2], location="vpp", owner="xlab")
    conn_settings.virtualhost = "/"
    conn_settings.port=5671
    conn_settings.use_ssl = True
    conn_settings.use_exchange=True
    conn_settings.certfile = sys.argv[3]
    conn_settings.keyfile = sys.argv[4]
    conn_settings.use_exchange=True

    thread = {}
    thread["sender"] = Connector_async.connector(conn_settings, workqueue=workQueue, queueLock=queueLock)
    thread["consumer"] = Connector_async.connector(conn_settings, listener=Consumer())
    ## start all threads
    for t in thread.values():
        t.daemon = True
        t.start()

    while True:
        interval_to = datetime.datetime.fromtimestamp(int(time.time() - 3500))
        interval_from = datetime.datetime.fromtimestamp(int(time.time() - 3500 - 60))
        res = 10
        signals = ["el.p"]
        getloadrep = GetReport(interval_from, interval_to, res, 'WaterHeater01', signals)
        print getloadrep.to_json()
        try:
            queueLock.acquire()
            try:
                logger.debug("add to send queue: " + str(getloadrep.to_json()))
                workQueue.put_nowait(getloadrep)
                queueLock.release()
            except Exception as err:
                logger.error("Queue err:" + str(err))

        except Exception as err:
            logger.error("error sending: " + str(err))
        time.sleep(5)
Esempio n. 2
0
            values[sig] = mes

        report = Report(request.from_, request.to, request.resolution, values)
        try:
            queueLock.acquire()
            try:
                workQueue.put_nowait(report)
                queueLock.release()
            except Exception as err:
                logger.error("Queue err:" + str(err))

        except Exception as err:
            logger.error("error sending: " + str(err))


conn_settings = Connector_Settings(sys.argv[1], sys.argv[2], location="heh", owner="xlab")
conn_settings.virtualhost = "/"
conn_settings.port = 5671
conn_settings.use_ssl = True
conn_settings.use_exchange = True
conn_settings.certfile = sys.argv[3]
conn_settings.keyfile = sys.argv[4]
conn_settings.use_exchange = True

thread = {}
thread["sender"] = Connector_async.connector(conn_settings, workqueue=workQueue, queueLock=queueLock)
thread["consumer"] = Connector_async.connector(conn_settings, listener=Consumer())
## start all threads
for t in thread.values():
    t.daemon = True
    t.start()