Frames per task

I’ve had a look at the nuke plugin (still unfamiliar with nuke though. Is this a think that you are going to do regulary? If yes I think the most robust way of getting data from Deadline into this script is doing a modification to the nuke plugin.

The Plugin does take your ScriptFilename to compile and execute the script in the monitored managed process

self.WritePython( "with open(\"{}\") as f: exec(compile(f.read(), \"{}\", 'exec'), globals(), locals()))".format(scriptFileName, scriptFileName) )

You should be able to replace that line with something like this to have a variable “deadlineTaskId” availabe in you script when it runs from the nuke plugin.

# Open and read the script
f = open(scriptFileName, 'r')
scriptContent = f.read()
f.close

# Add deadlineTaskId variable to the script
addTaskIdVar = "deadlineTaskId = " + self.getCurrentTaskId()
scriptWithVar = addTaskIdVar + '\n' + scriptContent

self.WritePython( "with open(\"{}\") as f: exec(compile(\"{}\", 'myscript', 'exec'), globals(), locals()))".format(scriptFileName, scriptWithVar) )

To get rid of API calls in your script you could also pass self.getCurrentTask().TaskFrameString directly this way.

Disclaimer: I didn’t test this nor did I check for naming conflicts. I don’t think injecting variables this way is particulary elegant but it’s the first I could come up with not having used compile() ever before.