-
-
Save jhodges10/a51cb7a30d7b1e1e452acd68a963cec8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import re | |
import os | |
from System import * | |
from System.IO import * | |
from Deadline.Scripting import * | |
def __main__( deadlinePlugin ): | |
job = deadlinePlugin.GetJob() | |
deadlinePlugin.LogInfo( "JobId: %s" % job.JobId ) | |
################################ JOB SETUP ################################### | |
# SHOTGUN_ENTITY_TYPE: The Shotgun Entity type, e.g. Shot | |
# SHOTGUN_ENTITY_ID: The Shotgun Entity id, e.g. 1234 | |
sg_task_id = job.GetJobExtraInfoKeyValue('TaskId') | |
sg_entity_id = job.GetJobExtraInfoKeyValue('EntityId') | |
sg_entity_name = job.GetJobExtraInfoKeyValue('EntityName') | |
sg_entity_type = job.GetJobExtraInfoKeyValue('EntityType') | |
os.environ['SHOTGUN_ENTITY_ID'] = sg_entity_id | |
os.environ['SHOTGUN_ENTITY_NAME'] = sg_entity_name | |
os.environ['SHOTGUN_ENTITY_TYPE'] = sg_entity_type | |
os.environ['SHOTGUN_TASK_ID'] = sg_task_id | |
deadlinePlugin.LogInfo( "Shotgun Task ID: {}".format(sg_task_id) ) | |
############################### SHOTGUN SETUP ################################ | |
# This script shows how a Toolkit as a plugin approach could be used to bootstrap | |
# Toolkit in Nuke on the render farm. | |
# http://developer.shotgunsoftware.com/tk-core/bootstrap.html#bootstrapping-toolkit | |
# TK_CORE_PATH = os.environ["SHOTGUN_SGTK_MODULE_PATH"] | |
# TK_CORE_PATH = sys.path.append(r"%APPDATA%\Shotgun\bundle_cache\app_store\tk-core\v0.19.3") | |
deadlinePlugin.LogInfo( "Shotgun: Loading sgtk" ) | |
sys.path.insert(0, "T:\\Python\\tk-core-0.19.3\\python") | |
import sgtk | |
deadlinePlugin.LogInfo( "Shotgun: sgtk loaded" ) | |
# Install to a shared folder | |
# http://developer.shotgunsoftware.com/tk-core/bootstrap.html#installing-the-sgtk-module-using-pip | |
# Authenticate using a pre-defined script user. | |
sa = sgtk.authentication.ShotgunAuthenticator() | |
# Setup Logging | |
sgtk.LogManager().initialize_custom_handler() | |
# Here we retrieve credentials from environment variables, assuming a script user | |
# will be used when rendering. This should be typically be handled by your render | |
# farm administrators. | |
SG_SITE_URL = "https://your_studio.shotgunstudio.com/" | |
SG_SCRIPT_USER = "Deadline" | |
SG_SCRIPT_KEY = "qwertyuioopsdghjgzvcxbn" | |
user = sa.create_script_user( | |
api_script=SG_SCRIPT_USER, | |
api_key=SG_SCRIPT_KEY, | |
host=SG_SITE_URL | |
) | |
# Start up a Toolkit Manager with our script user | |
mgr = sgtk.bootstrap.ToolkitManager(sg_user=user) | |
deadlinePlugin.LogInfo( "Shotgun: sgtk bootstrapped" ) | |
# Set the base pipeline configuration from the environment variable: | |
# mgr.base_configuration = os.environ["SHOTGUN_CONFIG_URI"] | |
mgr.base_configuration = "sgtk:descriptor:git?path=git://github.com/jhodges10/frame48-shotgun-config.git" | |
# Disable Shotgun lookup to ensure that we are getting the Pipeline | |
# Configuration defined in SHOTGUN_CONFIG_URI, and not a dev or override | |
# Pipeline Configuration defined in Shotgun. | |
mgr.do_shotgun_config_lookup = False | |
# Set a plugin id to indicate to the bootstrap that we are starting | |
# up a standard Nuke integration | |
mgr.plugin_id = "basic.nuke" | |
# Retrieve the Toolkit context from environment variables: | |
# SHOTGUN_SITE = SG_SITE_URL | |
# SHOTGUN_ENTITY_TYPE: The Shotgun Entity type, e.g. Shot | |
# SHOTGUN_ENTITY_ID: The Shotgun Entity id, e.g. 1234 | |
# sg_entity = mgr.get_entity_from_environment() # I think this will need to be modified | |
deadlinePlugin.LogInfo( "Shotgun: setting up engine for entity" ) | |
# Now start up the Nuke engine for a given Shotgun Entity | |
task = {"type": "Task", "id": 8861} | |
nuke_engine = mgr.bootstrap_engine("tk-nuke", entity=task) | |
deadlinePlugin.LogInfo( "Shotgun: Nuke engine loaded" ) | |
################################ END SHOTGUN SETUP ################################### | |
############################# BEGIN DEADLINE SETUP ################################### | |
deadlinePlugin.LogInfo( "Shotgun: begin loading scene" ) | |
nuke_script_path = job.SceneFile | |
new_context = nuke_engine.sgtk.context_from_path(nuke_script_path) | |
nuke_engine.change_context(new_context) | |
deadlinePlugin.LogInfo( "Shotgun: context changed based on script file submitted" ) | |
app = nuke_engine.apps["tk-nuke-writenode"] | |
deadlinePlugin.LogInfo( "Shotgun: tk-nuke-writenode loaded" ) | |
app.process_placeholder_nodes() | |
app.convert_to_write_nodes() | |
deadlinePlugin.LogInfo( "Shotgun: write nodes converted to default write nodes" ) | |
############################# SAVE FILE AND FINISH ################################### | |
deadlinePlugin.LogInfo( "Shotgun: saving file..." ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment