From 7666baa36a40639550a0169f0d88e6137e42fa40 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 14 Aug 2024 15:00:43 +0200 Subject: [PATCH 1/2] Refactor folder creation logic in FlameAppFramework - Removed unnecessary whitespace - Added code to create directories if they don't exist --- client/ayon_flame/api/lib.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/ayon_flame/api/lib.py b/client/ayon_flame/api/lib.py index 54afe50..59a74c5 100644 --- a/client/ayon_flame/api/lib.py +++ b/client/ayon_flame/api/lib.py @@ -146,7 +146,6 @@ def __init__(self): self.log.info("[{}] waking up".format(self.__class__.__name__)) - try: self.load_prefs() except RuntimeError: @@ -180,6 +179,15 @@ def load_prefs(self): (proj_pref_path, user_pref_path, glob_pref_path) = self.get_pref_file_paths() + # make directories if not exists + if not os.path.isdir(self.prefs_folder): + try: + os.makedirs(self.prefs_folder) + except Exception as err: + self.log.error( + f"Unable to create folder {self.prefs_folder}") + raise err + with io_preferences_file(self, proj_pref_path) as prefs_file: self.prefs = pickle.load(prefs_file) self.log.info( From 6f65839215f5b5d5213d285efccff966127c9335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Je=C5=BEek?= Date: Tue, 10 Sep 2024 14:58:28 +0200 Subject: [PATCH 2/2] Update client/ayon_flame/api/lib.py Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_flame/api/lib.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/client/ayon_flame/api/lib.py b/client/ayon_flame/api/lib.py index 59a74c5..25d0d6a 100644 --- a/client/ayon_flame/api/lib.py +++ b/client/ayon_flame/api/lib.py @@ -180,13 +180,12 @@ def load_prefs(self): glob_pref_path) = self.get_pref_file_paths() # make directories if not exists - if not os.path.isdir(self.prefs_folder): - try: - os.makedirs(self.prefs_folder) - except Exception as err: - self.log.error( - f"Unable to create folder {self.prefs_folder}") - raise err + try: + os.makedirs(self.prefs_folder, exist_ok=True) + except Exception as err: + self.log.error( + f"Unable to create folder {self.prefs_folder}") + raise err with io_preferences_file(self, proj_pref_path) as prefs_file: self.prefs = pickle.load(prefs_file)