jsdh
1
Hi,
As you can tell from the title I want to submit a new job from my Post Job Script:
from Deadline.Scripting import *
def __main__(*args):
deadline_plugin = args[0]
job = deadline_plugin.GetJob()
Could someone provide some sample code please?#
Thanks
This script wasn’t intended to be started from post job script so you need to adapt args to your needs.
import tempfile
import getpass
from System.IO import Path
from Deadline.Scripting import RepositoryUtils, ClientUtils
def submitJob(jobName, project, shot, frames, inputDir, outputDir):
deadlineTemp = ClientUtils.GetDeadlineTempPath()
jobInfoFile = ""
pluginInfoFile = ""
# Build job info file
with tempfile.NamedTemporaryFile(mode="w", dir=deadlineTemp, delete=False) as fileHandle:
jobInfoFile = fileHandle.name
fileHandle.write("Plugin=PlugName\n")
fileHandle.write("Name=Plug Name {0}\n".format(jobName))
fileHandle.write("BatchName={0}\n".format("Daily"))
fileHandle.write("Comment=Submited from script\n")
fileHandle.write("Department={0}\n".format("comp"))
fileHandle.write("UserName={0}\n".format(getpass.getuser()))
fileHandle.write("Pool={0}\n".format("pool"))
fileHandle.write("SecondaryPool={0}\n".format("None"))
fileHandle.write("Group={0}\n".format("group"))
fileHandle.write("Priority={0}\n".format(50))
fileHandle.write("OutputDirectory0={0}\n".format(Path.GetDirectoryName(outputDir)))
fileHandle.write("OutputFilename0={0}\n".format(Path.GetFileName(inputDir)+".mp4"))
fileHandle.write("Frames={0}\n".format(frames))
fileHandle.write("ChunkSize=1000000\n")
# Build plugin info file
with tempfile.NamedTemporaryFile(mode="w", dir=deadlineTemp, delete=False) as fileHandle:
pluginInfoFile = fileHandle.name
fileHandle.write('InputDir="%s"\n' % inputDir)
fileHandle.write('OutputDir="%s"\n' % outputDir)
fileHandle.write("Project=%s\n" % project )
fileHandle.write("Shot=%s\n" % shot )
RepositoryUtils.SubmitJob([jobInfoFile, pluginInfoFile])
def __main__(*args):
if len(args) < 5:
raise Exception("Invalid number of arguments")
name = args[0]
project = args[1]
shot = args[2]
frames = args[3]
inputDir = args[4]
if len(args) == 6:
outputDir = args[5]
else:
outputDir = inputDir
submitJob(name, project, shot, frames, inputDir, outputDir)
1 Like
jsdh
3
Thank you! This worked for me