adjusted config

This commit is contained in:
DJ2LS 2024-02-18 20:31:01 +01:00
parent 7f86ab2ece
commit e90d1f7716
2 changed files with 7 additions and 8 deletions

View file

@ -1,5 +1,5 @@
[NETWORK]
modemport = 3050
modemport = 5000
[STATION]
mycall = AA1AAA

View file

@ -147,9 +147,7 @@ class CONFIG:
self.parser.set(section, setting, str(default_value))
self.log.info(f"[CFG] Adding missing setting: {section}.{setting}")
self.write_to_file()
return self.write_to_file()
# Handle special setting data type conversion
# is_writing means data from a dict being writen to the config file
@ -177,7 +175,6 @@ class CONFIG:
def write(self, data):
# Validate config data before writing
self.validate_data(data)
for section in data:
# init section if it doesn't exist yet
if not section.upper() in self.parser.keys():
@ -186,9 +183,11 @@ class CONFIG:
for setting in data[section]:
new_value = self.handle_setting(
section, setting, data[section][setting], True)
self.parser[section][setting] = str(new_value)
self.write_to_file()
try:
self.parser[section][setting] = str(new_value)
except Exception as e:
self.log.error("[CFG] error setting config key", e=e)
return self.write_to_file()
def write_to_file(self):
# Write config data to file