Mercurial > libervia-backend
changeset 3482:acb28399480f
tools (config): show a warning when no config file has been found + don't use hardcoded filename in `fixConfigOption`
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 20 Mar 2021 20:42:07 +0100 (2021-03-20) |
parents | 7892585b7e17 |
children | 5945c24cd745 |
files | sat/tools/config.py |
diffstat | 1 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/sat/tools/config.py Sat Mar 20 20:42:07 2021 +0100 +++ b/sat/tools/config.py Sat Mar 20 20:42:07 2021 +0100 @@ -58,7 +58,9 @@ break if not target_file: # ... otherwise we create a new config file for that user - target_file = BaseDirectory.save_config_path("sat") + "/sat.conf" + target_file = ( + f"{BaseDirectory.save_config_path(C.APP_NAME_FILE)}/{C.APP_NAME_FILE}.conf" + ) if section and section.upper() != DEFAULTSECT and not config.has_section(section): config.add_section(section) config.set(section, option, value) @@ -84,9 +86,14 @@ log.error(_("Can't read main config: {msg}").format(msg=e), exc_info=True) else: if log_filenames: - log.info( - _("Configuration was read from: {filenames}").format( - filenames=', '.join(filenames))) + if filenames: + log.info( + _("Configuration was read from: {filenames}").format( + filenames=', '.join(filenames))) + else: + log.warning( + _("No configuration file found, using default settings") + ) return config