mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
implement validate_job_path and register it in houdini callbacks
This commit is contained in:
parent
fef45ceea2
commit
59a20fe0fb
2 changed files with 40 additions and 1 deletions
|
|
@ -9,9 +9,14 @@ import json
|
|||
|
||||
import six
|
||||
|
||||
from openpype.lib import StringTemplate
|
||||
from openpype.client import get_asset_by_name
|
||||
from openpype.settings import get_current_project_settings
|
||||
from openpype.pipeline import get_current_project_name, get_current_asset_name
|
||||
from openpype.pipeline.context_tools import get_current_project_asset
|
||||
from openpype.pipeline.context_tools import (
|
||||
get_current_context_template_data,
|
||||
get_current_project_asset
|
||||
)
|
||||
|
||||
import hou
|
||||
|
||||
|
|
@ -747,3 +752,31 @@ def get_camera_from_container(container):
|
|||
|
||||
assert len(cameras) == 1, "Camera instance must have only one camera"
|
||||
return cameras[0]
|
||||
|
||||
|
||||
def validate_job_path():
|
||||
"""Validate job path to ensure it matches the settings."""
|
||||
|
||||
project_settings = get_current_project_settings()
|
||||
|
||||
if project_settings["houdini"]["general"]["job_path"]["enabled"]:
|
||||
|
||||
# get and resolve job path template
|
||||
job_path_template = project_settings["houdini"]["general"]["job_path"]["path"]
|
||||
job_path = StringTemplate.format_template(
|
||||
job_path_template, get_current_context_template_data()
|
||||
)
|
||||
job_path = job_path.replace("\\","/")
|
||||
|
||||
if job_path == "":
|
||||
# Set JOB path to HIP path if JOB path is enabled
|
||||
# and has empty value.
|
||||
job_path = os.environ["HIP"]
|
||||
|
||||
current_job = hou.hscript("echo -n `$JOB`")[0]
|
||||
if current_job != job_path:
|
||||
hou.hscript("set JOB=" + job_path)
|
||||
os.environ["JOB"] = job_path
|
||||
print(" - set $JOB to " + job_path)
|
||||
else:
|
||||
print(" - JOB Path is disabled, Skipping Check...")
|
||||
|
|
|
|||
|
|
@ -300,6 +300,9 @@ def on_save():
|
|||
|
||||
log.info("Running callback on save..")
|
||||
|
||||
# Validate $JOB value
|
||||
lib.validate_job_path()
|
||||
|
||||
nodes = lib.get_id_required_nodes()
|
||||
for node, new_id in lib.generate_ids(nodes):
|
||||
lib.set_id(node, new_id, overwrite=False)
|
||||
|
|
@ -335,6 +338,9 @@ def on_open():
|
|||
|
||||
log.info("Running callback on open..")
|
||||
|
||||
# Validate $JOB value
|
||||
lib.validate_job_path()
|
||||
|
||||
# Validate FPS after update_task_from_path to
|
||||
# ensure it is using correct FPS for the asset
|
||||
lib.validate_fps()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue