| |
@@ -1,6 +1,7 @@
|
| |
# -*- coding: utf-8 -*-
|
| |
# SPDX-License-Identifier: MIT
|
| |
from __future__ import absolute_import
|
| |
+ import errno
|
| |
import imp
|
| |
import logging
|
| |
import os
|
| |
@@ -108,15 +109,27 @@
|
| |
to configure Flask with.
|
| |
:rtype: tuple(Config, object)
|
| |
"""
|
| |
- config_file = os.environ.get("MBS_CONFIG_FILE", "/etc/module-build-service/config.py")
|
| |
+ env_config_file = os.environ.get("MBS_CONFIG_FILE")
|
| |
+ if env_config_file is None:
|
| |
+ config_file = "/etc/module-build-service/config.py"
|
| |
+ else:
|
| |
+ config_file = env_config_file
|
| |
+
|
| |
+ config_module = None
|
| |
+
|
| |
+ # MBS_CONFIG_FILE="" entirely suppresses looking a config file
|
| |
+ if config_file != "":
|
| |
+ try:
|
| |
+ config_module = imp.load_source("mbs_runtime_config", config_file)
|
| |
+ log.info("Using the configuration file at %s", config_file)
|
| |
+ except OSError as e:
|
| |
+ if e.errno != errno.ENOENT or env_config_file:
|
| |
+ log.error("Can't open config file: %s", e)
|
| |
|
| |
- try:
|
| |
- config_module = imp.load_source("mbs_runtime_config", config_file)
|
| |
- log.info("Using the configuration file at %s", config_file)
|
| |
- except Exception:
|
| |
- log.warning("The configuration file at %s was not present", config_file)
|
| |
+ if config_module is None:
|
| |
# Default to this file as the configuration module
|
| |
config_module = sys.modules[__name__]
|
| |
+ log.debug("Using default configuration")
|
| |
|
| |
true_options = ("1", "on", "true", "y", "yes")
|
| |
if any(["py.test" in arg or "pytest" in arg for arg in sys.argv]):
|
| |
Right now, if there is no /etc/module-build-service/config.py (which is the expected situation for local builds against Fedora), a warning is printed at startup. The same warning is printed if loading the config file throws any sort of exception.
configuration file
Note: not on my critical path - has just been bugging me for a while (and confusing people trying to use the new module-build-service on Fedora, though that's further confused because there is a stray /etc/module-build-service/config.py packaged in the RPM.)