From 84175aaa786f5e97b538e89951b63bf4602d5b98 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Mon, 14 Dec 2020 19:00:10 +0100 Subject: [PATCH] modified loading of hooks to look for them also in host folder --- pype/lib/applications.py | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/pype/lib/applications.py b/pype/lib/applications.py index 115db43930..cae270aca2 100644 --- a/pype/lib/applications.py +++ b/pype/lib/applications.py @@ -575,19 +575,38 @@ class ApplicationLaunchContext: def paths_to_launch_hooks(self): """Directory paths where to look for launch hooks.""" # This method has potential to be part of application manager (maybe). - - # TODO find better way how to define dir path to default launch hooks - import pype - pype_dir = os.path.dirname(os.path.abspath(pype.__file__)) - hooks_dir = os.path.join(pype_dir, "hooks") + paths = [] # TODO load additional studio paths from settings # TODO add paths based on used modules (like `ftrack`) - paths = [] - subfolder_names = ["global", self.host_name, self.app_name] + import pype + pype_dir = os.path.dirname(os.path.abspath(pype.__file__)) + + # --- START: Backwards compatibility --- + hooks_dir = os.path.join(pype_dir, "hooks") + + subfolder_names = ["global", self.host_name] for subfolder_name in subfolder_names: path = os.path.join(hooks_dir, subfolder_name) - if os.path.exists(path) and os.path.isdir(path): + if ( + os.path.exists(path) + and os.path.isdir(path) + and path not in paths + ): + paths.append(path) + # --- END: Backwards compatibility --- + + subfolders_list = ( + ("hooks", "global"), + ("hosts", "tvpaint", self.host_name) + ) + for subfolders in subfolders_list: + path = os.path.join(pype_dir, *subfolders) + if ( + os.path.exists(path) + and os.path.isdir(path) + and path not in paths + ): paths.append(path) return paths