From: Michael Tremer Date: Sat, 7 Oct 2017 11:22:32 +0000 (+0100) Subject: Always load default configuration file X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=565ca1d1b5c20036aa3b24efd1004a009ef8b0f8;p=pbs.git Always load default configuration file Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/__init__.py b/src/buildservice/__init__.py index d82cae1e..3e8843e1 100644 --- a/src/buildservice/__init__.py +++ b/src/buildservice/__init__.py @@ -28,6 +28,9 @@ from . import updates from . import uploads from . import users +log = logging.getLogger("backend") +log.propagate = 1 + # Import version from .__version__ import VERSION as __version__ @@ -35,7 +38,7 @@ from .decorators import * from .constants import * class Backend(object): - def __init__(self, config_file="pbs.conf"): + def __init__(self, config_file=None): # Read configuration file. self.config = self.read_config(config_file) @@ -68,7 +71,19 @@ class Backend(object): def read_config(self, path): c = ConfigParser.SafeConfigParser() - c.read(path) + + # Load default configuration file first + paths = [ + os.path.join(CONFIGSDIR, "pbs.conf"), + ] + + if path: + paths.append(path) + + # Load all configuration files + for path in paths: + log.debug("Loading configuration from %s" % path) + c.read(path) return c diff --git a/src/hub/__init__.py b/src/hub/__init__.py index 0c722a3d..0b2e6247 100644 --- a/src/hub/__init__.py +++ b/src/hub/__init__.py @@ -79,9 +79,7 @@ class Application(tornado.web.Application): @property def pakfire(self): if self.__pakfire is None: - config_file = os.path.join(BASEDIR, "..", "pbs.conf") - - self.__pakfire = Backend(config_file=config_file) + self.__pakfire = Backend() return self.__pakfire diff --git a/src/web/__init__.py b/src/web/__init__.py index c34ec552..82f9fb3c 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -260,9 +260,7 @@ class Application(tornado.web.Application): @property def pakfire(self): if self.__pakfire is None: - config_file = os.path.join(BASEDIR, "..", "pbs.conf") - - self.__pakfire = Backend(config_file=config_file) + self.__pakfire = Backend() return self.__pakfire