def main(): '''Main. Parse cmdline, read config etc.''' args = arg_parse() if args.config_item: config = ini_to_dict(args.config, args.config_item) else: config = read_yaml(args.config) print("Setting timezone to UTC") os.environ["TZ"] = "UTC" time.tzset() handlers = [] if args.log: handlers.append( logging.handlers.TimedRotatingFileHandler(args.log, "midnight", backupCount=7)) handlers.append(logging.StreamHandler()) if args.verbose: loglevel = logging.DEBUG else: loglevel = logging.INFO for handler in handlers: handler.setFormatter( logging.Formatter( "[%(levelname)s: %(asctime)s :" " %(name)s] %(message)s", '%Y-%m-%d %H:%M:%S')) handler.setLevel(loglevel) logging.getLogger('').setLevel(loglevel) logging.getLogger('').addHandler(handler) logging.getLogger("posttroll").setLevel(logging.INFO) logger = logging.getLogger("segment_gatherer") gatherer = SegmentGatherer(config) gatherer.set_logger(logger) try: gatherer.run() finally: gatherer.stop()
def main(): """Parse cmdline, read config etc.""" args = arg_parse() if args.config_item: config = ini_to_dict(args.config, args.config_item) else: config = read_yaml(args.config) print("Setting timezone to UTC") os.environ["TZ"] = "UTC" time.tzset() setup_logging(args, "segment_gatherer") gatherer = SegmentGatherer(config) try: gatherer.run() finally: gatherer.stop()
def test_ini_to_dict(self): """Test ini conversion to dict.""" config = ini_to_dict(os.path.join(THIS_DIR, "data/segments.ini"), "msg") self.assertTrue('patterns' in config) self.assertTrue('posttroll' in config) self.assertTrue('time_tolerance' in config) self.assertTrue('timeliness' in config) self.assertTrue('num_files_premature_publish' in config) self.assertTrue('topics' in config['posttroll']) self.assertTrue('nameservers' in config['posttroll']) self.assertTrue('addresses' in config['posttroll']) self.assertTrue('topics' in config['posttroll']) self.assertTrue('publish_port' in config['posttroll']) self.assertTrue('publish_topic' in config['posttroll']) self.assertTrue('msg' in config['patterns']) self.assertTrue('pattern' in config['patterns']['msg']) self.assertTrue('critical_files' in config['patterns']['msg']) self.assertTrue('wanted_files' in config['patterns']['msg']) self.assertTrue('all_files' in config['patterns']['msg']) self.assertTrue('is_critical_set' in config['patterns']['msg']) self.assertTrue('variable_tags' in config['patterns']['msg'])
from pytroll_collectors.helper_functions import read_yaml from pytroll_collectors.segments import (SLOT_NOT_READY, SLOT_NONCRITICAL_NOT_READY, SLOT_READY, SLOT_READY_BUT_WAIT_FOR_MORE, SLOT_OBSOLETE_TIMEOUT) THIS_DIR = os.path.dirname(os.path.abspath(__file__)) CONFIG_SINGLE = read_yaml(os.path.join(THIS_DIR, "data/segments_single.yaml")) CONFIG_DOUBLE = read_yaml(os.path.join(THIS_DIR, "data/segments_double.yaml")) CONFIG_DOUBLE_DIFFERENT = read_yaml(os.path.join(THIS_DIR, "data/segments_double_different.yaml")) CONFIG_NO_SEG = read_yaml(os.path.join(THIS_DIR, "data/segments_double_no_segments.yaml")) CONFIG_INI = ini_to_dict(os.path.join(THIS_DIR, "data/segments.ini"), "msg") CONFIG_INI_NO_SEG = ini_to_dict(os.path.join(THIS_DIR, "data/segments.ini"), "goes16") CONFIG_INI_HIMAWARI = ini_to_dict(os.path.join(THIS_DIR, "data/segments.ini"), "himawari-8") class TestSegmentGatherer(unittest.TestCase): """Tests for the segment gatherer.""" def setUp(self): """Set up the testing.""" self.mda_msg0deg = {"segment": "EPI", "uid": "H-000-MSG3__-MSG3________-_________-EPI______-201611281100-__", "platform_shortname": "MSG3", "start_time": dt.datetime(2016, 11, 28, 11, 0, 0), "nominal_time": dt.datetime( # noqa 2016, 11, 28, 11, 0, 0), "uri": "/home/lahtinep/data/satellite/geo/msg/H-000-MSG3__-MSG3________-_________-EPI______-201611281100-__", "platform_name": "Meteosat-10", "channel_name": "", "path": "", "sensor": ["seviri"], "hrit_format": "MSG3"} # noqa self.mda_iodc = {"segment": "EPI", "uid": "H-000-MSG2__-MSG2_IODC___-_________-EPI______-201611281100-__", "platform_shortname": "MSG2", "start_time": dt.datetime(2016, 11, 28, 11, 0, 0), "nominal_time": dt.datetime( # noqa
from pytroll_collectors.segments import SegmentGatherer, ini_to_dict from pytroll_collectors.helper_functions import read_yaml from pytroll_collectors.segments import (SLOT_NOT_READY, SLOT_NONCRITICAL_NOT_READY, SLOT_READY, SLOT_READY_BUT_WAIT_FOR_MORE, SLOT_OBSOLETE_TIMEOUT) THIS_DIR = os.path.dirname(os.path.abspath(__file__)) CONFIG_SINGLE = read_yaml(os.path.join(THIS_DIR, "data/segments_single.yaml")) CONFIG_DOUBLE = read_yaml(os.path.join(THIS_DIR, "data/segments_double.yaml")) CONFIG_NO_SEG = read_yaml( os.path.join(THIS_DIR, "data/segments_double_no_segments.yaml")) CONFIG_INI = ini_to_dict(os.path.join(THIS_DIR, "data/segments.ini"), "msg") class TestSegmentGatherer(unittest.TestCase): def setUp(self): """Setting up the testing """ self.mda_msg0deg = { "segment": "EPI", "uid": "H-000-MSG3__-MSG3________-_________-EPI______-201611281100-__", "platform_shortname": "MSG3", "start_time": dt.datetime(2016, 11, 28, 11, 0, 0), "nominal_time": dt.datetime(2016, 11, 28, 11, 0, 0), "uri": "/home/lahtinep/data/satellite/geo/msg/H-000-MSG3__-MSG3________-_________-EPI______-201611281100-__",