Bases: PreLaunchHook
Launch arguments preparation.
Hook add python executable and script path to Harmony implementation before Harmony executable and add last workfile path to launch arguments.
Existence of last workfile is checked. If workfile does not exists tries to copy templated workfile from predefined path.
Source code in client/ayon_harmony/hooks/pre_launch_args.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113 | class HarmonyPrelaunchHook(PreLaunchHook):
"""Launch arguments preparation.
Hook add python executable and script path to Harmony implementation
before Harmony executable and add last workfile path to launch arguments.
Existence of last workfile is checked. If workfile does not exists tries
to copy templated workfile from predefined path.
"""
app_groups = {"harmony"}
order = 20
launch_types = {LaunchTypes.local}
def execute(self):
self._enable_version_menu()
# 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 = get_launch_script_path()
new_launch_args = get_ayon_launcher_args(
"run", script_path, executable_path
)
# Add workfile path if exists
workfile_path = self.data.get("workfile_path")
last_workfile_path = self.data["last_workfile_path"]
if workfile_path:
new_launch_args.append(workfile_path)
elif (
self.data.get("start_last_workfile")
and last_workfile_path
and os.path.exists(last_workfile_path)
):
new_launch_args.append(last_workfile_path)
workfile_startup = self.data.get("workfile_startup", True)
self.launch_context.env["AYON_HARMONY_WORKFILES_ON_LAUNCH"] = str(
int(workfile_startup)
)
# Append as whole list as these arguments should not be separated
self.launch_context.launch_args.append(new_launch_args)
if remainders:
self.launch_context.launch_args.extend(remainders)
self.launch_context.kwargs = get_launch_kwargs(
self.launch_context.kwargs
)
def _enable_version_menu(self):
"""Enable version menu in Harmony if enabled in settings."""
version_up_current_workfile: bool = (
self.data["project_settings"]
.get("core", {})
.get("tools", {})
.get("ayon_menu", {})
.get("version_up_current_workfile", False)
)
if version_up_current_workfile:
self.log.debug("Enabling 'Version Up' menu entry in Harmony.")
self.launch_context.env["AYON_HARMONY_VERSION_UP_WORKFILE"] = "1"
|