From cf87c34befa7ece1361b67142b8ebaea9d518bcc Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Fri, 30 Jun 2023 15:53:54 +0530 Subject: [PATCH] Allow main to switch back from yaml to json config files --- ui/easydiffusion/app.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ui/easydiffusion/app.py b/ui/easydiffusion/app.py index 38e3392c..7e9e7890 100644 --- a/ui/easydiffusion/app.py +++ b/ui/easydiffusion/app.py @@ -100,7 +100,22 @@ def init(): def getConfig(default_val=APP_CONFIG_DEFAULTS): try: config_json_path = os.path.join(CONFIG_DIR, "config.json") - if not os.path.exists(config_json_path): + + # compatibility with upcoming yaml changes, switching from beta to main + config_yaml_path = os.path.join(CONFIG_DIR, "config.yaml") + if os.path.exists(config_yaml_path): + try: + import yaml + + with open(config_yaml_path, "r", encoding="utf-8") as f: + config = yaml.safe_load(f) + + setConfig(config) # save to config.json + os.remove(config_yaml_path) # delete the yaml file + except: + log.warn(traceback.format_exc()) + config = default_val + elif not os.path.exists(config_json_path): config = default_val else: with open(config_json_path, "r", encoding="utf-8") as f: