def __init__(self, config): self.buff_size = config['general']['data_buffer_size'] self.output = config['general']['data_format'] self.counter = 0 self.buffer = [] self.data_handler = DataHandler(config) if 'csv' in self.output: logging_util.configure_logging('logging_config_csv.yaml') self.logger_csv = logging_util.get_logger('data_manager_csv') self.logger_csv.handlers[ 0].rotator = self.data_handler.data_logger_rotator self.logger_csv.handlers[ 0].namer = self.data_handler.data_logger_namer if 'json' in self.output: logging_util.configure_logging('logging_config_json.yaml') self.logger_json = logging_util.get_logger('data_manager_json') self.logger_json.handlers[ 0].rotator = self.data_handler.data_logger_rotator self.logger_json.handlers[ 0].namer = self.data_handler.data_logger_namer
import os import time import schedule import AWSIoTPublisher import logging_util logging_util.configure_logging('logging_config_main.yaml') logger = logging_util.get_logger(__name__) CONFIG_FILE = 'config.yaml' def publishScheduleJob(aws_iot, data_dir): import glob file_list = glob.glob(os.path.join(data_dir, '*.json')) aws_iot.publishMessages(file_list) def load_config(config_path): import yaml with open(config_path, 'r') as f: return yaml.safe_load(f.read()) def main(): config = load_config(os.path.join(os.path.dirname(__file__), CONFIG_FILE)) aws_iot = AWSIoTPublisher.AWSIoTPublisher(config['awsiot']) logger.info('Start AWSIoTPublisher') # AWSIoT(DynamoDB)にアップするスケジュール schedule.every(config['general']['interval']).minutes.at(":00").do(