/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import os, platform, sys, getopt ####################### CONFIG ## Put the path to the nuke exe here nkExePath = 'Z:/software/Nuke6.1v1_x64/Nuke6.1.exe --nukex' ## Put the path to NUKE_PATH here so nuke can find scripts. ## Set this to '' if you dont have anything for this. nkPath = 'z:/software/nuke_throb' def main(): # Parse command line options = 'h' longOptions = ['img=', 'out=', 'script=', 'startframe=', 'endframe=' ] opts, pargs = getopt.getopt(sys.argv[1:], options, longOptions) # Extract command line options for opt in opts: if opt[0] == '--img': img = opt[1] elif opt[0] == '--out': out = opt[1] elif opt[0] == '--script': script = opt[1] elif opt[0] == '--startframe': startframe = opt[1] elif opt[0] == '--endframe': endframe = opt[1] # Check for a command missingOpts = [] try: img except NameError: missingOpts.append('img') try: out except NameError: missingOpts.append('out') try: startframe except NameError: missingOpts.append('startframe') try: script except NameError: missingOpts.append('script') try: endframe except NameError: missingOpts.append('endframe') if len(missingOpts) > 0 : usage(missingOpts, longOptions) sys.exit(1) #job = getJob(img) #sequence = getSeq(img) #shot = getShot(img) #os.putenv('JOB',job) if nkPath != '': os.putenv('NUKE_PATH',nkPath) if os.path.exists(os.path.dirname(out)) == False: os.makedirs(os.path.dirname(out)) cmdLine = '%s -x %s %s %s %d,%d' % (nkExePath, script, img, out, int(startframe), int(endframe)) os.system(cmdLine) def usage (opts, allOpts): print '=' * 20, 'Usage','=' * 20, '\n' scriptOpts = '' scriptPath = os.path.basename(sys.argv[0]) for curOpt in allOpts: scriptOpts = '%s --%s [option]' % (scriptOpts, curOpt.replace('=','')) print '%s %s\n' % (scriptPath, scriptOpts) for opt in opts: print 'Option missing: %s\n' % opt if __name__ == '__main__': main() sys.exit(0)