mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
added harmony prelaunch
This commit is contained in:
parent
9940ff2fa9
commit
87d30338c4
1 changed files with 53 additions and 0 deletions
53
pype/hooks/harmony/pre_launch_args.py
Normal file
53
pype/hooks/harmony/pre_launch_args.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import os
|
||||
import platform
|
||||
|
||||
from pype.lib import PreLaunchHook
|
||||
|
||||
|
||||
class HarmonyPrelaunchHook(PreLaunchHook):
|
||||
"""Launch arguments preparation.
|
||||
|
||||
Hook add python executable and execute python script of harmony
|
||||
implementation before harmony executable.
|
||||
"""
|
||||
hosts = ["harmony"]
|
||||
|
||||
def execute(self):
|
||||
# Pop tvpaint executable
|
||||
photoshop_executable = 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))
|
||||
|
||||
python_launch_args = [
|
||||
self.python_executable(),
|
||||
"-c",
|
||||
(
|
||||
"^\"import avalon.harmony;"
|
||||
"avalon.harmony.launch(\"{}\")^\"\""
|
||||
).format(photoshop_executable)
|
||||
]
|
||||
if platform.system().lower() != "windows":
|
||||
new_launch_args = python_launch_args
|
||||
else:
|
||||
new_launch_args = [
|
||||
"cmd.exe",
|
||||
"/k",
|
||||
"\"{}\"".format(" ".join(python_launch_args))
|
||||
]
|
||||
|
||||
# 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 Harmony launch. {}"
|
||||
).format(str(remainders)))
|
||||
self.launch_context.launch_args.extend(remainders)
|
||||
|
||||
def python_executable(self):
|
||||
"""Should lead to python executable."""
|
||||
# TODO change in Pype 3
|
||||
return os.environ["PYPE_PYTHON_EXE"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue