diff --git a/app/classes/shared/helpers.py b/app/classes/shared/helpers.py index 778bfbfb..81606ba3 100644 --- a/app/classes/shared/helpers.py +++ b/app/classes/shared/helpers.py @@ -194,7 +194,6 @@ class Helpers: return cmd_out def get_setting(self, key, default_return=False): - try: with open(self.settings_file, "r", encoding="utf-8") as f: data = json.load(f) @@ -202,10 +201,8 @@ class Helpers: if key in data.keys(): return data.get(key) - else: - logger.error(f"Config File Error: setting {key} does not exist") - Console.error(f"Config File Error: setting {key} does not exist") - return default_return + logger.error(f'Config File Error: Setting "{key}" does not exist') + Console.error(f'Config File Error: Setting "{key}" does not exist') except Exception as e: logger.critical( @@ -217,22 +214,19 @@ class Helpers: return default_return - def set_setting(self, key, new_value, default_return=False): - + def set_setting(self, key, new_value): try: with open(self.settings_file, "r", encoding="utf-8") as f: data = json.load(f) if key in data.keys(): data[key] = new_value + with open(self.settings_file, "w", encoding="utf-8") as f: + json.dump(data, f, indent=2) + return True - else: - logger.error(f"Config File Error: setting {key} does not exist") - Console.error(f"Config File Error: setting {key} does not exist") - return default_return - - with open(self.settings_file, "w", encoding="utf-8") as f: - json.dump(data, f, indent=2) + logger.error(f'Config File Error: Setting "{key}" does not exist') + Console.error(f'Config File Error: Setting "{key}" does not exist') except Exception as e: logger.critical( @@ -241,6 +235,7 @@ class Helpers: Console.critical( f"Config File Error: Unable to read {self.settings_file} due to {e}" ) + return False @staticmethod def get_local_ip():