mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 05:42:15 +01:00
replaced prelaunch hooks of non python hosts with single global hook
This commit is contained in:
parent
9c0f86b5a1
commit
54020eb122
3 changed files with 12 additions and 126 deletions
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue