Exemple #1
0
                for i in range(0, int(ret)):
                    blinkled(GREEN, 0.05, True)
                    time.sleep(0.1)
            else:
                for i in range(0, 6):
                    blinkled(RED, 0.02, True)
                    time.sleep(0.05)
        else:
            for i in range(0, 7):
                blinkled(RED, 0.02, True)
                time.sleep(0.05)
        conn.close()

    channel.basic_ack(delivery_tag=method_frame.delivery_tag)


config = readconfig()
server = config.get('TIMR', 'server') or 'timr.solongo.office'
uri = config.get('TIMR', 'uri') or '/api/cardreader?id='

logger = create_logger('call-timr.log')
logger.info('Call-Timr: Start')
init_gpio()

queue = 'call-timr'
channel = get_receiver(queue, False)
channel.basic_consume(on_message, queue)

logger.info('Start Consuming.')
channel.start_consuming()
Exemple #2
0
#!/usr/bin/python
import json
from solongo.estools import store_es
from solongo.rmqtools import get_receiver
from solongo.tools import create_logger


def on_message(channel, method_frame, header_frame, body):
    logger.info("Got Message! Store in ES.")
    logger.debug(json.dumps(body, default=lambda o: o.__dict__))
    store_es(body)
    channel.basic_ack(delivery_tag=method_frame.delivery_tag)


logger = create_logger("store-es.log")
logger.info("Store-Es: Start")
queue = "store_es"
channel = get_receiver(queue, True)
channel.basic_consume(on_message, queue)

try:
    logger.info("Start consuming.")
    channel.start_consuming()
except KeyboardInterrupt:
    channel.close()