diff --git a/openpype/hosts/resolve/hooks/pre_resolve_launch_last_workfile.py b/openpype/hosts/resolve/hooks/pre_resolve_launch_last_workfile.py index 94c123e6f9..bc03baad8d 100644 --- a/openpype/hosts/resolve/hooks/pre_resolve_launch_last_workfile.py +++ b/openpype/hosts/resolve/hooks/pre_resolve_launch_last_workfile.py @@ -1,23 +1,17 @@ import os - from openpype.lib import PreLaunchHook -import openpype.hosts.resolve -class ResolveLaunchLastWorkfile(PreLaunchHook): +class PreLaunchResolveLastWorkfile(PreLaunchHook): """Special hook to open last workfile for Resolve. Checks 'start_last_workfile', if set to False, it will not open last workfile. This property is set explicitly in Launcher. """ - - # Execute after workfile template copy order = 10 app_groups = ["resolve"] def execute(self): - self.set_startup_script() - if not self.data.get("start_last_workfile"): self.log.info("It is set to not start last workfile on start.") return @@ -32,17 +26,9 @@ class ResolveLaunchLastWorkfile(PreLaunchHook): return # Add path to launch environment for the startup script to pick up - self.log.info(f"Setting OPENPYPE_RESOLVE_OPEN_ON_LAUNCH to launch " - f"last workfile: {last_workfile}") + self.log.info( + "Setting OPENPYPE_RESOLVE_OPEN_ON_LAUNCH to launch " + f"last workfile: {last_workfile}" + ) key = "OPENPYPE_RESOLVE_OPEN_ON_LAUNCH" self.launch_context.env[key] = last_workfile - - def set_startup_script(self): - # Set the openpype prelaunch startup script path for easy access - # in the LUA .scriptlib code - op_resolve_root = os.path.dirname(openpype.hosts.resolve.__file__) - script_path = os.path.join(op_resolve_root, "startup.py") - key = "OPENPYPE_RESOLVE_STARTUP_SCRIPT" - self.launch_context.env[key] = script_path - self.log.info("Setting OPENPYPE_RESOLVE_STARTUP_SCRIPT to: " - f"{script_path}") diff --git a/openpype/hosts/resolve/hooks/pre_resolve_startup_script.py b/openpype/hosts/resolve/hooks/pre_resolve_startup_script.py new file mode 100644 index 0000000000..599e0c0008 --- /dev/null +++ b/openpype/hosts/resolve/hooks/pre_resolve_startup_script.py @@ -0,0 +1,24 @@ +import os + +from openpype.lib import PreLaunchHook +import openpype.hosts.resolve + + +class PreLaunchResolveStartup(PreLaunchHook): + """Special hook to configure startup script. + + """ + order = 11 + app_groups = ["resolve"] + + def execute(self): + # Set the openpype prelaunch startup script path for easy access + # in the LUA .scriptlib code + op_resolve_root = os.path.dirname(openpype.hosts.resolve.__file__) + script_path = os.path.join(op_resolve_root, "startup.py") + key = "OPENPYPE_RESOLVE_STARTUP_SCRIPT" + self.launch_context.env[key] = script_path + + self.log.info( + f"Setting OPENPYPE_RESOLVE_STARTUP_SCRIPT to: {script_path}" + )