From b46f45268a44717ba83d9349de11f4763ba92e7d Mon Sep 17 00:00:00 2001 From: TinyNick Date: Thu, 13 Apr 2023 09:39:43 -0400 Subject: [PATCH 1/5] [Blender_Kitsu] Shot_Builder fix ensure_loaded_production() --- blender_kitsu/shot_builder/project.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/blender_kitsu/shot_builder/project.py b/blender_kitsu/shot_builder/project.py index d6de5442..c55fb50e 100644 --- a/blender_kitsu/shot_builder/project.py +++ b/blender_kitsu/shot_builder/project.py @@ -32,6 +32,7 @@ from blender_kitsu.shot_builder.hooks import Hooks, register_hooks from blender_kitsu.shot_builder.connectors.default import DefaultConnector from blender_kitsu.shot_builder.connectors.connector import Connector +import os from blender_kitsu import prefs from pathlib import Path @@ -400,16 +401,16 @@ def ensure_loaded_production(context: bpy.types.Context) -> bool: Returns if the production of for the given context is loaded. """ global _PRODUCTION - production_root = get_production_root(context) - if production_root is None: - _PRODUCTION = None - return False - if _PRODUCTION and (_PRODUCTION.path == production_root): - return True - - logger.debug( + addon_prefs = prefs.addon_prefs_get(bpy.context) + base_path = Path(addon_prefs.project_root_dir) + production_root = os.path.join(base_path, "pro") + if is_valid_production_root(Path(production_root)): + logger.debug( f"loading new production configuration from '{production_root}'.") - return __load_production_configuration(context, production_root) + __load_production_configuration(context, Path(production_root)) + return True + return False + def __load_production_configuration(context: bpy.types.Context, -- 2.30.2 From 6cc708704e7e72f0cfe0af0b784e3bee1da981d7 Mon Sep 17 00:00:00 2001 From: TinyNick Date: Thu, 13 Apr 2023 09:41:00 -0400 Subject: [PATCH 2/5] [Blender_Kitsu] Add error message if ensure_loaded_production() fails --- blender_kitsu/shot_builder/operators.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/blender_kitsu/shot_builder/operators.py b/blender_kitsu/shot_builder/operators.py index 03e2eb70..e127296e 100644 --- a/blender_kitsu/shot_builder/operators.py +++ b/blender_kitsu/shot_builder/operators.py @@ -171,7 +171,11 @@ class SHOTBUILDER_OT_NewShotFile(bpy.types.Operator): self.production_name = project.name - ensure_loaded_production(context) + if not ensure_loaded_production(context): + self.report( + {'ERROR'}, "Shot builder configuration files not found in current project directory. \nCheck addon preferences to ensure project root contains shot_builder config.") + return {'CANCELLED'} + production = get_active_production() -- 2.30.2 From 33d2e51e3d8b8ed723541971c22d7103569da29a Mon Sep 17 00:00:00 2001 From: TinyNick Date: Thu, 13 Apr 2023 09:41:56 -0400 Subject: [PATCH 3/5] [Blender_Kitsu] Make all error messages more read-able - Add new lines to error messages --- blender_kitsu/shot_builder/operators.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/blender_kitsu/shot_builder/operators.py b/blender_kitsu/shot_builder/operators.py index e127296e..0b56a721 100644 --- a/blender_kitsu/shot_builder/operators.py +++ b/blender_kitsu/shot_builder/operators.py @@ -149,22 +149,22 @@ class SHOTBUILDER_OT_NewShotFile(bpy.types.Operator): if addon_prefs.session.is_auth() is False: self.report( - {'ERROR'}, "Must be logged into Kitsu to continue. Check login status in 'Blender Kitsu' addon preferences.") + {'ERROR'}, "Must be logged into Kitsu to continue. \nCheck login status in 'Blender Kitsu' addon preferences.") return {'CANCELLED'} if project.id == "": self.report( - {'ERROR'}, "Operator is not able to determine the Kitsu production's name. Check project is selected in 'Blender Kitsu' addon preferences.") + {'ERROR'}, "Operator is not able to determine the Kitsu production's name. \nCheck project is selected in 'Blender Kitsu' addon preferences.") return {'CANCELLED'} if not addon_prefs.is_project_root_valid: self.report( - {'ERROR'}, "Operator is not able to determine the project root directory. Check project root directiory is configured in 'Blender Kitsu' addon preferences.") + {'ERROR'}, "Operator is not able to determine the project root directory. \nCheck project root directiory is configured in 'Blender Kitsu' addon preferences.") return {'CANCELLED'} if not addon_prefs.is_editorial_dir_valid: self.report( - {'ERROR'}, "Shot builder is dependant on a valid editorial export path and file pattern. Check Preferences, errors appear in console") + {'ERROR'}, "Shot builder is dependant on a valid editorial export path and file pattern. \nCheck Preferences, errors appear in console") return {'CANCELLED'} self.production_root = addon_prefs.project_root_dir -- 2.30.2 From 56dcfea7dbba7ef855ada8f52701ed5f91f47ea1 Mon Sep 17 00:00:00 2001 From: TinyNick Date: Thu, 13 Apr 2023 09:42:16 -0400 Subject: [PATCH 4/5] [Blender_Kitsu] Shot_Builder remove no_op code --- blender_kitsu/shot_builder/operators.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/blender_kitsu/shot_builder/operators.py b/blender_kitsu/shot_builder/operators.py index 0b56a721..852d7603 100644 --- a/blender_kitsu/shot_builder/operators.py +++ b/blender_kitsu/shot_builder/operators.py @@ -178,10 +178,6 @@ class SHOTBUILDER_OT_NewShotFile(bpy.types.Operator): production = get_active_production() - - self.production_root = addon_prefs.project_root_dir - self.production_name = project.name - global _production_task_type_items _production_task_type_items = production.get_task_type_items( context=context) -- 2.30.2 From 25571ec39b6355336b11595accb126acdbad2d6a Mon Sep 17 00:00:00 2001 From: TinyNick Date: Thu, 13 Apr 2023 09:43:59 -0400 Subject: [PATCH 5/5] [Blender_Kitsu] Shot_Builder add future TODO on hotfix --- blender_kitsu/shot_builder/project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blender_kitsu/shot_builder/project.py b/blender_kitsu/shot_builder/project.py index c55fb50e..cad3ffd5 100644 --- a/blender_kitsu/shot_builder/project.py +++ b/blender_kitsu/shot_builder/project.py @@ -403,7 +403,7 @@ def ensure_loaded_production(context: bpy.types.Context) -> bool: global _PRODUCTION addon_prefs = prefs.addon_prefs_get(bpy.context) base_path = Path(addon_prefs.project_root_dir) - production_root = os.path.join(base_path, "pro") + production_root = os.path.join(base_path, "pro") #TODO Fix during refactor should use base_path if is_valid_production_root(Path(production_root)): logger.debug( f"loading new production configuration from '{production_root}'.") -- 2.30.2