mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
separate the startup script logic from workfile hook
This commit is contained in:
parent
8b5722c0a2
commit
3e9ac5935d
2 changed files with 29 additions and 19 deletions
|
|
@ -1,23 +1,17 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from openpype.lib import PreLaunchHook
|
from openpype.lib import PreLaunchHook
|
||||||
import openpype.hosts.resolve
|
|
||||||
|
|
||||||
|
|
||||||
class ResolveLaunchLastWorkfile(PreLaunchHook):
|
class PreLaunchResolveLastWorkfile(PreLaunchHook):
|
||||||
"""Special hook to open last workfile for Resolve.
|
"""Special hook to open last workfile for Resolve.
|
||||||
|
|
||||||
Checks 'start_last_workfile', if set to False, it will not open last
|
Checks 'start_last_workfile', if set to False, it will not open last
|
||||||
workfile. This property is set explicitly in Launcher.
|
workfile. This property is set explicitly in Launcher.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Execute after workfile template copy
|
|
||||||
order = 10
|
order = 10
|
||||||
app_groups = ["resolve"]
|
app_groups = ["resolve"]
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
self.set_startup_script()
|
|
||||||
|
|
||||||
if not self.data.get("start_last_workfile"):
|
if not self.data.get("start_last_workfile"):
|
||||||
self.log.info("It is set to not start last workfile on start.")
|
self.log.info("It is set to not start last workfile on start.")
|
||||||
return
|
return
|
||||||
|
|
@ -32,17 +26,9 @@ class ResolveLaunchLastWorkfile(PreLaunchHook):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Add path to launch environment for the startup script to pick up
|
# Add path to launch environment for the startup script to pick up
|
||||||
self.log.info(f"Setting OPENPYPE_RESOLVE_OPEN_ON_LAUNCH to launch "
|
self.log.info(
|
||||||
f"last workfile: {last_workfile}")
|
"Setting OPENPYPE_RESOLVE_OPEN_ON_LAUNCH to launch "
|
||||||
|
f"last workfile: {last_workfile}"
|
||||||
|
)
|
||||||
key = "OPENPYPE_RESOLVE_OPEN_ON_LAUNCH"
|
key = "OPENPYPE_RESOLVE_OPEN_ON_LAUNCH"
|
||||||
self.launch_context.env[key] = last_workfile
|
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}")
|
|
||||||
|
|
|
||||||
24
openpype/hosts/resolve/hooks/pre_resolve_startup_script.py
Normal file
24
openpype/hosts/resolve/hooks/pre_resolve_startup_script.py
Normal file
|
|
@ -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}"
|
||||||
|
)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue