We're messing around with writing our own
submit script in python..
is there a good place to start?
Yes; have a look at:
http://www.seriss.com/rush-current/rush/rush-submit.html#Python-Irush
This shows a simple python script that submits a job as well as
manages its rendering.
This example is actually written in several languages on that same
page, so it's kind of a 'Rosetta Stone' for the different languages.
In the case of the python script shown, it handles batching.
You would just need to tweak in some Maya specifics (eg. setting
Maya 2011 environment variables for the different platforms, and
invoking the maya "Render" command)
Here is a slightly modified version of that script that does just
that.
I've highlighted in red the Maya
specific stuff added, to help you out.
The text in green is the text to
change for the job you want to submit.
#!/usr/bin/python
import os,sys,re
# Parse jobid from rush submit
def ParseJobid(rushoutfile):
rushout = open(rushoutfile, 'r')
rushout_lines = ""
while 1:
line = rushout.readline()
if ( line == "" ):
break
rushout_lines += line
print rushout_lines
rushout.close()
return(re.search("RUSH_JOBID.(\S+)", rushout_lines).groups()[0])
# SUBMIT THE JOB IF NO ARGS SPECIFIED
if len(sys.argv) <= 1:
if ( os.environ.has_key("RUSH_ISDAEMON") ): # Prevent 'network worm' style recursion
sys.exit(1)
# User should change these as needed
title = "MY_TEST" # Title
ram = 10 # Ram this job needs
sfrm = 1 # Start frame
efrm = 23 # End frame
batch = 5 # Batch frames (1 for none)
scene = "//meade/net/tmp/scenes/foo.ma" # Scene file to render
logdir = "//meade/net/tmp/logs" # Log directory based on scene pathname
cpus = "+any=5.1@1" # Cpus the job should use
# Create log directory if none
if ( not os.path.isdir(logdir) ):
os.mkdir(logdir, 0777)
# SUBMIT THE JOB
# Save output to a temp file so we can parse back jobid..
#
tmpfile = "/var/tmp"
if ( os.path.isdir("c:/temp") ):
tmpfile = "c:/temp"
tmpfile = "%s/submit-out.%d" % ( tmpfile, os.getpid() )
# Submit the job
submit = os.popen("rush -submit > " + tmpfile, 'w')
submit.write("title %s\n" % title +
"ram %d\n" % ram +
"frames %d-%d,%d\n" % ( sfrm, efrm, batch) +
"logdir %s\n" % logdir +
"command python %s -render %s %s %s\n" % ( sys.argv[0], scene, batch, efrm ) +
"cpus %s\n" % cpus)
err = submit.close()
# Read submit output, parse jobid, remove tmp file
os.environ["RUSH_JOBID"] = ParseJobid(tmpfile);
os.remove(tmpfile)
# Submit Failed
if ( err or os.environ["RUSH_JOBID"] == "" ):
sys.exit(1)
# Submit OK
print "--- Starting irush.." # optional
os.system("irush -button Frames") # optional
sys.exit(0)
# RENDERING ON REMOTE MACHINE?
if ( sys.argv[1] == "-render" ):
# Set maya environment variables
if ( os.path.isdir("c:/") ):
### WIN
os.environ["PATH"] = "c:/Program Files/Autodesk/Maya2011/bin;" + os.environ["PATH"]
elif ( os.path.isdir("/Applications") ):
### MAC
os.environ["PATH"] = "/Applications/Autodesk/maya2011/Maya.app/Contents/bin:" + os.environ["PATH"]
elif ( os.path.isdir("/usr/autodesk") ):
### LINUX
os.environ["PATH"] = "/usr/autodesk/maya2011/bin:" + os.environ["PATH"]
scene = sys.argv[2]
batch = int(sys.argv[3])
lastfrm = int(sys.argv[4])
sfrm = int(os.environ["RUSH_FRAME"])
efrm = int(os.environ["RUSH_FRAME"]) + batch - 1
if ( efrm > lastfrm ):
efrm = lastfrm
# PRINT FRAMES BEING RENDERED
if ( sfrm == efrm ):
print "--- Working on frame %d" % sfrm
else:
print "--- Working on frames %d - %d" % ( sfrm, efrm )
# START RENDER, CHECK FOR ERRORS
cmd = "Render -s %d -e %d %s" % ( sfrm, efrm, sys.argv[2] )
print "--- Executing: %s" % cmd
sys.stdout.flush()
err = os.system(cmd)
if err:
print "--- Render failed (EXIT CODE=%s)" % (err >> 8) # Failed? show error code
sys.exit(1) # 'sys.exit(1)' tells rush frame "Fail"
print "--- Render OK" # Worked?
sys.exit(0) # 'sys.exit(0)' tells rush frame "Done"
# BAD ARGUMENT
stderr.write("%s: unknown argument %s\n" % ( sys.argv[0], sys.argv[1] ) )
sys.exit(1)
--
Greg Ercolano, erco@(email surpressed)
Seriss Corporation
Rush Render Queue, http://seriss.com/rush/
Tel: (Tel# suppressed)ext.23
Fax: (Tel# suppressed)
Cel: (Tel# suppressed)
|