I notice that the Draft submitter has a field called “Additional Args”. Can this be used to send information to Draft scripts? And if so, how do you use it? I’d like to send some information that will get burned into a Quicktime that Draft is creating.
The short answer is ‘yes’, but I’ll go into more detail since I get the feeling that you’re not too familiar with Python.
So, the “Additional Args” just get appended to the arguments passed to the Draft script, which are accessible within the script using ‘sys.argv’. Technically, it can be formatted however you want if you’re willing to parse through it yourself.
However, we do provide a utility module along with Draft to assist in parsing out command line parameters (DraftParamParser), which expects arguments to be formatted in a key-value pair format (e.g., “key=value”), separated by spaces. The way you use this in the script itself is to pass the expected keys along with their types, as well as the sys.argv of that script.
The above piece of code tells our utility script to look for arguments with keys named username, entity, version, etc., and specifies which type each of these should be. Valid type strings are ‘’, ‘’, ‘’, and lists of these, as such: ‘(, , , …)’.
The ‘ParseCommandLine’ function returns a dictionary in which the values found for these keys can be accessed via a subscript (e.g., in the above, “print params[‘username’]” would print out the username).
By default, Deadline will pass in a number of arguments into the script for you already. This includes the following:
username – A string, specified by the user at submission time (Defaults to Shotgun user or Deadline user, usually)
entity – A string, specified by the user at submission time
version – A string, specified by the user at submission time
startFrame – An integer, pulled from the scene or Deadline job properties
endFrame – An integer, pulled from the scene or Deadline job properties
frameList – A string, pulled from the scene or Deadline job properties
inFile – A string, the input file for the Draft job (usually a frame sequence)
outFile – A string, the intended output location for the Draft job
deadlineJobID – A string, the JobID for the original Deadline job on which the Draft job is based (not always applicable).
So, to sum things up, if you wanted to pass an extra argument to the Draft script (say, your favourite colour), you’d put something like the following in your “Additional Args” box when you’re submitting jobs:
favColour="Blue"
In order to handle this in the script itself, you’d have to add a line to the snippet above (below the similar lines, that is) that says:
expectedTypes['favColour'] = '<string>'
Then, once you made the call to ParseCommandLine, you can access the value of ‘favColour’ through the dictionary like so:
params = ParseCommandLine( expectedTypes, sys.argv )
# Prints out "Blue" to the log
print params[ 'favColour' ]
Hope this helps, and I hope I didn’t lose you anywhere along the way
I’m just now getting back to playing with Draft. I looked into the param argument passing. I didn’t realize it was THIS easy to pass stuff to Draft. Very easy, very awesome.