tools (config): show a warning when no config file has been found + don't use hardcoded filename in fixConfigOption

This commit is contained in:
Goffi 2021-03-20 20:42:07 +01:00
commit e39783de7f

View file

@ -58,7 +58,9 @@ def fixConfigOption(section, option, value, silent=True):
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 @@ def parseMainConf(log_filenames=False):
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