Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/buildservice/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/buildservice/__init__.py b/src/buildservice/__init__.py index be81ba0..9619bfe 100644 --- a/src/buildservice/__init__.py +++ b/src/buildservice/__init__.py @@ -84,8 +84,11 @@ class Backend(object):
# Load all configuration files for path in paths: - log.debug("Loading configuration from %s" % path) - c.read(path) + if os.path.exists(path): + log.debug("Loading configuration from %s" % path) + c.read(path) + else: + log.error("No such file %s" % path)
return c
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/buildservice/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/buildservice/__init__.py b/src/buildservice/__init__.py index 9619bfe..7a744f5 100644 --- a/src/buildservice/__init__.py +++ b/src/buildservice/__init__.py @@ -94,10 +94,13 @@ class Backend(object):
@lazy_property def db(self): - name = self.config.get("database", "name") - hostname = self.config.get("database", "hostname") - user = self.config.get("database", "user") - password = self.config.get("database", "password") + try: + name = self.config.get("database", "name") + hostname = self.config.get("database", "hostname") + user = self.config.get("database", "user") + password = self.config.get("database", "password") + except ConfigParser.Error as e: + log.error("Error parsing the config: %s" % e.message)
log.debug("Connecting to database %s @ %s" % (name, hostname))
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/buildservice/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/src/buildservice/__init__.py b/src/buildservice/__init__.py index 7a744f5..b9f3e65 100644 --- a/src/buildservice/__init__.py +++ b/src/buildservice/__init__.py @@ -74,6 +74,12 @@ class Backend(object): def read_config(self, path): c = ConfigParser.SafeConfigParser()
+ c.add_section("database") + c.set("database", "name", os.environ.get("PBS_DATABASE_NAME")) + c.set("database", "hostname", os.environ.get("PBS_DATABASE_HOSTNAME")) + c.set("database", "user", os.environ.get("PBS_DATABASE_USER")) + c.set("database", "password", os.environ.get("PBS_DATABASE_PASSWORD")) + # Load default configuration file first paths = [ os.path.join(CONFIGSDIR, "pbs.conf"),