From e85c55f7a02020007d09617b3708683e446f4b5c Mon Sep 17 00:00:00 2001 From: Goffi Date: Sun, 23 Jun 2019 17:40:19 +0200 Subject: [PATCH] core (config): if flatpak is detected, config is also looked after in /app --- sat/core/constants.py | 19 ++++++++++++++----- sat/tools/config.py | 1 + 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/sat/core/constants.py b/sat/core/constants.py index a65462e7..046a0e52 100644 --- a/sat/core/constants.py +++ b/sat/core/constants.py @@ -209,6 +209,19 @@ class Const(object): + ".conf" ] else: + import os + CONFIG_PATHS = ( + ["/etc/", "~/", "~/.", "", "."] + + [ + "%s/" % path + for path in list(BaseDirectory.load_config_paths(APP_NAME_FILE)) + ] + ) + + if os.getenv('FLATPAK_ID'): + # for Flatpak, the conf can't be set in /etc or $HOME, so we have + # to add /app + CONFIG_PATHS.append('/app') ## Configuration ## DEFAULT_CONFIG = { @@ -222,11 +235,7 @@ class Const(object): # List of the configuration filenames sorted by ascending priority CONFIG_FILES = [ realpath(expanduser(path) + APP_NAME_FILE + ".conf") - for path in ["/etc/", "~/", "~/.", "", "."] - + [ - "%s/" % path - for path in list(BaseDirectory.load_config_paths(APP_NAME_FILE)) - ] + for path in CONFIG_PATHS ] ## Templates ## diff --git a/sat/tools/config.py b/sat/tools/config.py index f0894b08..e383c173 100644 --- a/sat/tools/config.py +++ b/sat/tools/config.py @@ -32,6 +32,7 @@ from sat.core import exceptions log = getLogger(__name__) + def fixConfigOption(section, option, value, silent=True): """Force a configuration option value, writing it in the first found user config file, eventually creating a new user config file if none is found.