Exemple #1
0
def post_simple_sensors():

    sensors_json = request.get_json(force=True)
    logging.debug(sensors_json)
    parser = SimpleSensorParser()
    events = parser.convert_to_events(sensors_json)

    event_ids = []
    for event in events:
        event_id = messagebus.send_message(event)
        event_ids.append(event_id)

    return "Posted Messages: " + str(event_ids)
class SimpleSensorPublisherProcess():

    def __init__(self, connection, url):
        self.logger = logging.getLogger("SimpleSensorPublisherProcess")
        self.connection = connection
        self.client = MessageBusClient(url)
        self.parser = SimpleSensorParser()

    def start(self):
        while True:
            line = connection.readline()
            events = self.parser.parse(line)
            for event in events:
                self.client.send_message(event)
 def __init__(self, connection, url):
     self.logger = logging.getLogger("SimpleSensorPublisherProcess")
     self.connection = connection
     self.client = MessageBusClient(url)
     self.parser = SimpleSensorParser()