|
These are simple examples of combination submit/render
scripts; there's a Perl version,
and a DOS batch version. Use either
one; the perl version is more portable.
To keep the examples simple, there's no frame batching
or any fancy stuff.
Be sure to change the red text to names
relevant on your system.
PERL: Maya Submit / Render
|
#!/usr/bin/perl
# SIMPLE MAYA PERL SUBMIT EXAMPLE
# Shows the easiest way to make a self contained
# submit/render script. This script should work on Windows or Unix.
#
$|=1;
umask(0);
# NEED ABSOULUTE PATH TO SELF
my $self = $0;
if ( $self !~ m%^[/\\]% && $self !~ m%^[a-zA-Z]:% )
{ my $pwd=`pwd`; chomp($pwd); $self = "$pwd/$0"; }
# MAIN
{
if ( $#ARGV < 1 )
{
print STDERR "USAGE\n".
" $0 scenefile framerange [imagedir]\n\n".
"EXAMPLE\n".
" $self //tahoe/net/tmp/scenes/foo.ma 1-20,2\n\n";
exit(1);
}
# INVOKED AS A RENDER SCRIPT?
# Then rush is calling us to render a frame.
# Create maya command line and run it, checking for errors.
#
if ( $ARGV[0] eq "-render" )
{
shift(@ARGV);
my ($scenefile,$imagedir) = @ARGV;
$imagedir = ( $imagedir eq "-" ) ? "" : "-rd $imagedir";
my $cmd = "render -s $ENV{RUSH_FRAME} -e $ENV{RUSH_FRAME} $imagedir $scenefile";
print " SCENE=$scenefile\n".
"IMAGEDIR=$scenefile\n".
" FRAME=$ENV{RUSH_PADFRAME}\n".
"\n".
"Executing: $cmd\n";
my $exitcode = system($cmd) >> 8;
if ( $exitcode )
{
print STDERR "MAYA FAILED: EXITCODE=$exitcode\n";
exit(1); # "Fail"
}
print STDERR "MAYA SUCCEEDED: EXITCODE=$exitcode\n";
exit(0); # "Done"
}
else
{
# INVOKED AS A SUBMIT SCRIPT?
# Get args from command line, and submit to rush
#
my ($scenefile,$frames,$imagedir) = @ARGV;
if ( $imagedir eq "" )
{ $imagedir = "-"; }
# MAKE SURE SCENEFILE AND LOGDIR EXISTS
if ( ! -e "$scenefile" )
{ print "$scenefile: does not exist\n"; exit(1); }
if ( ! -d "$scenefile.log" )
{
unless ( mkdir("$scenefile.log", 0777) )
{ print STDERR "mkdir '$scenefile.log': $!\n"; exit(1); }
}
# SUBMIT THE JOB
# Pipe the submit commands into 'rush -submit'.
#
unless ( open(SUBMIT, "|rush -submit") )
{ print STDERR "$0: 'rush -submit': $!\n"; exit(1); }
print SUBMIT <<"EOF";
title MAYA
ram 10
frames $frames
logdir $scenefile.log/%s
command perl $self -render $scenefile $imagedir
cpus +any=10\@100
EOF
# CHECK IF SUBMIT SUCCEEDED
# If failed, exit non-zero, error message on stderr.
#
close(SUBMIT);
if ( $? >> 8 )
{ print STDERR "-- submit failed --\n"; exit(1); }
exit(0);
}
#NOTREACHED
}
|
Here's a similar script written as a DOS batch script.
Because DOS is very limited in its string manipulation
ability (it practically has none), this script is not
as featured as the Perl version.
Be sure to change the red text to names
relevant on your system.
DOS: Maya Submit / Render
|
@echo off
REM ###
REM ### DOS BATCH -- MAYA SUBMIT/RENDER SCRIPT
REM ### Works on Windows *only*
REM ###
REM ### USER SHOULD CHANGE THESE!!
REM ### Use UNC style absolute pathnames with front "/" slashes.
REM ###
set MAYASCENE=//tahoe/net/tmp/scenes/foo.mb
set MAYAPROJECT=//tahoe/net/tmp
set MAYALOGDIR=//tahoe/net/tmp/scenes/foo.mb.log
set MAYACPUS=+any=10@100
if "%1"=="-render" goto RENDER
REM ######################
REM ### SUBMIT SECTION ###
REM ######################
:SUBMIT
set TMPDIR=c:\temp
set SUBMIT=c:\temp\$$$.bat
set SELF=%0
set SELF=%SELF:\=/%
(
echo title TEST
echo ram 1
echo frames 1-20
echo logdir %MAYALOGDIR%
echo command cmd /c %SELF% -render
echo cpus %MAYACPUS%
) | rush -submit > %SUBMIT%
if %ERRORLEVEL% GEQ 1 goto DONE
call %SUBMIT%
del %SUBMIT%
echo RUSH_JOBID is %RUSH_JOBID%
start /b irush
goto DONE
REM ######################
REM ### RENDER SECTION ###
REM ######################
:RENDER
echo MAYA SCENE=%MAYASCENE%
echo MAYA PROJECT=%MAYAPROJECT%
@echo on
@echo EXECUTING MAYA:
render -verbose 1 -proj %MAYAPROJECT% -s %RUSH_FRAME% -e %RUSH_FRAME% -b 1 %MAYASCENE%
@set ERR=%ERRORLEVEL%
@echo off
if %ERR% EQU 128 goto REQUEUE128
if %ERR% GTR 0 goto FAIL
echo --- MAYA SUCCEEDS: EXITCODE=%ERR%
exit 0
:FAIL
echo --- MAYA FAILED: EXITCODE=%ERR%
exit 1
:REQUEUE128
echo --- MAYA INDICATES LICENSE ERROR (EXIT 128)
echo --- ADDING THIS MACHINE AS NEVERHOST AND REQUEING
rush -fu an %RUSH_HOSTNAME%
exit 2
:DONE
|
|
|
|