diff --git a/pype/hooks/aftereffects/pre_launch_args.py b/pype/hooks/aftereffects/pre_launch_args.py deleted file mode 100644 index 340fa8c9db..0000000000 --- a/pype/hooks/aftereffects/pre_launch_args.py +++ /dev/null @@ -1,54 +0,0 @@ -import os - -import avalon -from pype.lib import ( - PreLaunchHook, - get_pype_execute_args -) - - -class AfterEffectsPrelaunchHook(PreLaunchHook): - """Launch arguments preparation. - - Hook add python executable and execute python script of AfterEffects - implementation before AfterEffects executable. - """ - app_groups = ["aftereffects"] - - def execute(self): - # Pop executable - executable_path = self.launch_context.launch_args.pop(0) - - # Pop rest of launch arguments - There should not be other arguments! - remainders = [] - while self.launch_context.launch_args: - remainders.append(self.launch_context.launch_args.pop(0)) - - script_path = self.get_launch_script_path() - new_launch_args = get_pype_execute_args( - "run", script_path, executable_path - ) - # Add workfile path if exists - workfile_path = self.data["last_workfile_path"] - if os.path.exists(workfile_path): - new_launch_args.append(workfile_path) - - # Append as whole list as these arguments should not be separated - self.launch_context.launch_args.append(new_launch_args) - - if remainders: - self.log.warning(( - "There are unexpected launch arguments " - "in AfterEffects launch. {}" - ).format(str(remainders))) - self.launch_context.launch_args.extend(remainders) - - def get_launch_script_path(self): - """Path to launch script of photoshop implementation.""" - avalon_dir = os.path.dirname(os.path.abspath(avalon.__file__)) - script_path = os.path.join( - avalon_dir, - "AfterEffects", - "launch_script.py" - ) - return script_path diff --git a/pype/hooks/harmony/pre_launch_args.py b/pype/hooks/global/pre_non_python_host_launch.py similarity index 60% rename from pype/hooks/harmony/pre_launch_args.py rename to pype/hooks/global/pre_non_python_host_launch.py index 619c91a522..87b6cbad01 100644 --- a/pype/hooks/harmony/pre_launch_args.py +++ b/pype/hooks/global/pre_non_python_host_launch.py @@ -1,19 +1,20 @@ import os -import avalon from pype.lib import ( PreLaunchHook, get_pype_execute_args ) +import pype.PACKAGE_DIR -class HarmonyPrelaunchHook(PreLaunchHook): +class NonPythonHostHook(PreLaunchHook): """Launch arguments preparation. - Hook add python executable and execute python script of harmony - implementation before harmony executable. + Non python host implementation do not launch host directly but use + python script which launch the host. For these cases it is necessary to + prepend python (or pype) executable and script path before application's. """ - app_groups = ["harmony"] + app_groups = ["harmony", "photoshop", "aftereffects"] def execute(self): # Pop executable @@ -24,7 +25,12 @@ class HarmonyPrelaunchHook(PreLaunchHook): while self.launch_context.launch_args: remainders.append(self.launch_context.launch_args.pop(0)) - script_path = self.get_launch_script_path() + script_path = os.path.join( + pype.PACKAGE_DIR, + "scripts", + "non_python_host_launch.py" + ) + new_launch_args = get_pype_execute_args( "run", script_path, executable_path ) @@ -37,17 +43,4 @@ class HarmonyPrelaunchHook(PreLaunchHook): self.launch_context.launch_args.append(new_launch_args) if remainders: - self.log.warning(( - "There are unexpected launch arguments in Harmony launch. {}" - ).format(str(remainders))) self.launch_context.launch_args.extend(remainders) - - def get_launch_script_path(self): - """Path to launch script of photoshop implementation.""" - avalon_dir = os.path.dirname(os.path.abspath(avalon.__file__)) - script_path = os.path.join( - avalon_dir, - "harmony", - "launch_script.py" - ) - return script_path diff --git a/pype/hooks/photoshop/pre_launch_args.py b/pype/hooks/photoshop/pre_launch_args.py deleted file mode 100644 index 91c5e78325..0000000000 --- a/pype/hooks/photoshop/pre_launch_args.py +++ /dev/null @@ -1,53 +0,0 @@ -import os - -import avalon -from pype.lib import ( - PreLaunchHook, - get_pype_execute_args -) - - -class PhotoshopPrelaunchHook(PreLaunchHook): - """Launch arguments preparation. - - Hook add python executable and execute python script of photoshop - implementation before photoshop executable. - """ - app_groups = ["photoshop"] - - def execute(self): - # Pop executable - executable_path = self.launch_context.launch_args.pop(0) - - # Pop rest of launch arguments - There should not be other arguments! - remainders = [] - while self.launch_context.launch_args: - remainders.append(self.launch_context.launch_args.pop(0)) - - script_path = self.get_launch_script_path() - new_launch_args = get_pype_execute_args( - "run", script_path, executable_path - ) - # Add workfile path if exists - workfile_path = self.data["last_workfile_path"] - if os.path.exists(workfile_path): - new_launch_args.append(workfile_path) - - # Append as whole list as these areguments should not be separated - self.launch_context.launch_args.append(new_launch_args) - - if remainders: - self.log.warning(( - "There are unexpected launch arguments in Photoshop launch. {}" - ).format(str(remainders))) - self.launch_context.launch_args.extend(remainders) - - def get_launch_script_path(self): - """Path to launch script of photoshop implementation.""" - avalon_dir = os.path.dirname(os.path.abspath(avalon.__file__)) - script_path = os.path.join( - avalon_dir, - "photoshop", - "launch_script.py" - ) - return script_path