Пример #1
0
    def __init__(self):
        try:
            self.log_config = config.load_config("logging")
        except config.HeaderNotFound:
            error("Configuration does not have a \"logging\" header. See")
            error("example_config.json for details on setting up your config file.")  # noqa
            sys.exit(1)

        if not self.is_valid_config():
            sys.exit(1)
Пример #2
0
    def is_valid_config(self):
        LOGGING_SCHEMA = Schema({
            Required("debug"): bool,
            Required("log_path"): self.is_valid_dir_path,
            Required("append_log"): bool
        })

        try:
            LOGGING_SCHEMA(self.log_config)
        except MultipleInvalid as e:
            error("Error parsing logging configuration.")
            error(e)
            return False
        return True
Пример #3
0
def _load_config_json():
    try:
        with open(CONFIG_FILE_PATH, 'r') as config:
            return json.load(config)
    except IOError:
        error("Couldn't load config file. Exiting.")
        sys.stderr.flush()
        sys.exit(1)
    except ValueError:  # Error on loading the json itself.
        error("Couldn't load config file JSON.  Formatting error?")
        error("system shutting down.")
        sys.stderr.flush()
        sys.exit(1)