From 1f617031fdf2c4d7499c6ad7b0e3314cd9e20c9c Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Wed, 12 Jun 2024 20:44:09 +0200 Subject: common.load_config(): Don't fail when curdir is not traversable. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Path().joinpath('config.yml').exists() raises an exception when the process doesn't have permission to traverse the current directory. This is the case, in particular, when running webmap-* as another user via sudo while in the “normal” home directory. --- common.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common.py b/common.py index e1c13ab..247e733 100644 --- a/common.py +++ b/common.py @@ -48,10 +48,12 @@ def load_config(path=None, groupnames=None): for p in [Path(), Path(xdg_config_home).joinpath('webmap'), PosixPath('/etc').joinpath('webmap')]: - p = p.joinpath('config.yml') - if p.exists(): - path = str(p) + p = str(p.joinpath('config.yml')) + if os.path.exists(p): + path = p break + if path is None: + raise Exception('Could not find configuration file') with open(path, 'r') as fp: config = yaml.safe_load(fp) layers = config.get('layers', {}) -- cgit v1.2.3