コード例 #1
0
def main():
    """Stalk an s3 bucket."""
    args = arg_parse()

    bucket = args.bucket
    config = read_yaml(args.config)

    if args.log is not None:
        with open(args.log) as fd:
            log_dict = yaml.safe_load(fd.read())
            logging.config.dictConfig(log_dict)

    try:
        publish_new_files(bucket, config)
    except KeyboardInterrupt:
        print("terminating publisher...")
コード例 #2
0
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()
コード例 #3
0
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()
コード例 #4
0
import os
import os.path
import logging

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_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):