From 7a5a5e18cee4407f57ac3e8d08e6f076e3e301fe Mon Sep 17 00:00:00 2001 From: Robert Rosca <robert.rosca@xfel.eu> Date: Thu, 15 Jul 2021 23:16:07 +0200 Subject: [PATCH] Use absolute path for user config files --- webservice/serve_overview.py | 3 ++- webservice/update_mdc.py | 4 ++-- webservice/webservice.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/webservice/serve_overview.py b/webservice/serve_overview.py index ca7680905..5df38aff8 100644 --- a/webservice/serve_overview.py +++ b/webservice/serve_overview.py @@ -5,6 +5,7 @@ import sqlite3 from collections import OrderedDict from datetime import datetime, timezone from http.server import BaseHTTPRequestHandler, HTTPServer +from pathlib import Path from subprocess import check_output from typing import Optional @@ -345,7 +346,7 @@ class RequestHandler(BaseHTTPRequestHandler): def run(config_file = Optional[str]): if config_file is not None: - config.configure(includes_for_dynaconf=[config_file]) + config.configure(includes_for_dynaconf=[Path(config_file).absolute()]) with open(config["web-service"]["cal-config"], "r") as cf: global cal_config diff --git a/webservice/update_mdc.py b/webservice/update_mdc.py index b9240a840..fd68354ad 100644 --- a/webservice/update_mdc.py +++ b/webservice/update_mdc.py @@ -1,5 +1,5 @@ import argparse -import os.path as osp +from pathlib import Path from metadata_client.metadata_client import MetadataClient @@ -23,7 +23,7 @@ flg = args['flg'] msg = args['msg'] if conf_file is not None: - config.configure(includes_for_dynaconf=[conf_file]) + config.configure(includes_for_dynaconf=[Path(conf_file).absolute()]) mdconf = config['metadata-client'] client_conn = MetadataClient(client_id=mdconf['user-id'], diff --git a/webservice/webservice.py b/webservice/webservice.py index 19baea828..bf61dec8c 100644 --- a/webservice/webservice.py +++ b/webservice/webservice.py @@ -1139,7 +1139,7 @@ def main(argv: Optional[List[str]] = None): mode = args.mode if config_file is not None: - config.configure(includes_for_dynaconf=['config_file']) + config.configure(includes_for_dynaconf=[Path(config_file).absolute()]) fmt = '%(asctime)s - %(name)s - %(levelname)s - [%(filename)s:%(lineno)d] %(message)s' logging.basicConfig( -- GitLab