Exemplo n.º 1
0
                                   include_access_points=False,
                                   id='Wifi',
                                   )

    wifi_logger = LogFileWriter(writer_id="Wifi",
                                filename="wifi_devices.log",
                                path="/mnt/sda1/",
                                formatter=WiFiFormatter(),
                                file_time_prefix="%Y-%m-%d ",
                                timestamp_format=None,
                                )

    ingestor = SinkNode(logger_level=logging.DEBUG)
    # ingestor.add_reader(yun_reader)
    ingestor.add_reader(wifi_reader)

    # ingestor.add_writer(traffic_log_writer)
    # ingestor.add_writer(bluetooth_logger)
    # ingestor.add_writer(thingspeak_writer)
    ingestor.add_writer(wifi_logger)

    ingestor.start()

    try:
        while True:
            pass

    except KeyboardInterrupt:
        ingestor.stop()
        sys.exit()
Exemplo n.º 2
0
    console_handler.setFormatter(logging.Formatter(log_format))
    logger.addHandler(console_handler)

    # File Logging
    if log_filename:
        file_handler = logging.FileHandler(log_filename)
        file_handler.setFormatter(logging.Formatter(log_format))
        file_handler.setLevel(file_logger_level)
        logger.addHandler(file_handler)


if __name__ == "__main__":
    yun_reader = SerialReader(SERIAL_BAUD, SERIAL_PORT, start_delimiter=PACKET_START, stop_delimiter=PACKET_STOP)

    log_writer = LogFileWriter(log_filename, CSVFormatter())
    uploader = ThingspeakWriter("trafficCount", "KY7G0UVNHA25GQ73", TRAFFIC_KEY_MAP)

    ingestor = SinkNode()
    ingestor.add_reader(yun_reader)
    ingestor.add_logger(log_writer)
    ingestor.add_writer(uploader)

    ingestor.start()

    try:
        while True:
            pass

    except KeyboardInterrupt:
        sys.exit()