From bd88647f0b08a293821385389539bedf392751ca Mon Sep 17 00:00:00 2001 From: Stefan Allius <122395479+s-allius@users.noreply.github.com> Date: Thu, 22 May 2025 21:29:41 +0200 Subject: [PATCH] fix the paths to copy the config.example.toml file (#425) --- CHANGELOG.md | 1 + app/src/cnf/config.py | 14 ++++++++------ app/src/server.py | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df55052..116ef15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] +- fix the paths to copy the config.example.toml file during proxy start - add MQTT topic `dcu_power` for setting output power on DCUs - Update ghcr.io/hassio-addons/base Docker tag to v17.2.5 - fix a lot of pytest-asyncio problems in the unit tests diff --git a/app/src/cnf/config.py b/app/src/cnf/config.py index 5207c7d..207fbe8 100644 --- a/app/src/cnf/config.py +++ b/app/src/cnf/config.py @@ -162,7 +162,8 @@ class Config(): ) @classmethod - def init(cls, def_reader: ConfigIfc, log_path: str = '') -> None | str: + def init(cls, def_reader: ConfigIfc, log_path: str = '', + cnf_path: str = 'config') -> None | str: '''Initialise the Proxy-Config Copy the internal default config file into the config directory @@ -173,12 +174,13 @@ and initialise the Config with the default configuration ''' try: # make the default config transparaent by copying it # in the config.example file - logging.debug('Copy Default Config to config.example.toml') + logging.info( + f'Copy Default Config to {cnf_path}config.example.toml') - shutil.copy2("default_config.toml", - "config/config.example.toml") - except Exception: - pass + shutil.copy2("cnf/default_config.toml", + cnf_path + "config.example.toml") + except Exception as e: + logging.error(e) # read example config file as default configuration try: diff --git a/app/src/server.py b/app/src/server.py index 26ee093..60a2fe8 100644 --- a/app/src/server.py +++ b/app/src/server.py @@ -127,7 +127,8 @@ class Server(): def build_config(self): # read config file Config.init(ConfigReadToml(self.src_dir + "cnf/default_config.toml"), - log_path=self.log_path) + log_path=self.log_path, + cnf_path=self.config_path) ConfigReadEnv() ConfigReadJson(self.config_path + "config.json") ConfigReadToml(self.config_path + "config.toml")