aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2024-06-12 20:44:09 +0200
committerGuilhem Moulin <guilhem@fripost.org>2024-06-12 20:52:45 +0200
commit1f617031fdf2c4d7499c6ad7b0e3314cd9e20c9c (patch)
treef0c31c5e7c4a89ebce66a147362510edc4071d97
parent6c42b9221b66ab1891f3f553fc72a7d5f8d65f58 (diff)
common.load_config(): Don't fail when curdir is not traversable.
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.
-rw-r--r--common.py8
1 files 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', {})