Exemplo n.º 1
0
    def makeScripts(self):
        ''' Generate the render scripts and the qsub submission script '''

        print 'generating scripts in ... %s' % self.wd

        #if self.publishscene:

        mb_path = "%s/mb/" % (self.wd)

        if not os.path.isdir(mb_path):
            mkfolder(mb_path)

        publishedfile = "%s/%s" % (mb_path, os.path.basename(self.scenefile))

        if not os.path.isfile(publishedfile):
            print "Copying scene file ..."
            org_size = os.path.getsize(self.scenefile)
            shutil.copyfile(self.scenefile, publishedfile)

        self.scenefile = publishedfile

        self.createJobScript()
        self.createQsubExecScript()

        return self.createQsubExecScript()
Exemplo n.º 2
0
    def setPaths(self):
        ''' Set the paths for pantry based resources '''

        #
        # Changed for the renders to go to the user directory
        #

        if not 'out_dir' in self.paths:
            self.paths['out_dir'] = "%s/renders/%s/%s/" % (
                self.envs['USER_PATH'], self.layer, self.render_pass)

        # everything below relys on the version being set
        self.setVersion()

        self.paths['pantry'] = _os.path.join(self.paths['out_dir'],
                                             "v%03d" % self.version, '.pantry')

        self.setWD(self.paths['pantry'])

        mkfolder(self.wd)

        self.paths['mb_path'] = '%s/mb' % self.wd

        self.paths['scripts_path'] = '%s/scripts' % self.wd

        if not 'img_path' in self.paths:
            self.paths['img_path'] = "%s/v%03d/%s" % (str(
                self.paths['out_dir']), int(self.version), 'x'.join(
                    map(str, self.res.values())))
Exemplo n.º 3
0
	def makeScripts(self):		
		''' Generate the render scripts and the qsub submission script '''
		
		print 'generating scripts in ... %s' % self.wd
		
		if self.publishscene:
			
			mb_path = "%s/mb/" % (self.wd)
			
			if not os.path.isdir(mb_path):
				mkfolder(mb_path)		
			
			publishedfile="%s/%s" % (mb_path,os.path.basename(self.scenefile))
			
			if not os.path.isfile(publishedfile):
				print "Copying scene file ..."
				org_size=os.path.getsize(self.scenefile)
				shutil.copyfile(self.scenefile,publishedfile)
			
			
			self.scenefile = publishedfile
		
		
		
		self.createRenderScript()
		self.createPostScripts()
		#self.createQsubExecScript()
	
		return self.createQsubExecScript()
Exemplo n.º 4
0
    def setPaths(self):
        ''' Set the paths for pantry based resources (tdls,sdls,shadowmaps) '''
        
        #
        # Changed for the renders to go to the user directory
        #
        
        self.paths['out_dir']=''
        
        # This will be obsolete
        # if '3d_builds' in _os.path.abspath(self.envs['WORKSPACE_PATH']):
        #     self.paths['out_dir']="%s/render_tmp/%s/%s/%s/" % (self.envs['WORKSPACE_PATH'],self.camera.split(':')[-1],self.layer,self.render_pass)
        # else:
        #     self.paths['out_dir']="%s/3d/render_tmp/%s/%s/%s/" % (self.envs['WORKSPACE_PATH'],self.camera.split(':')[-1],self.layer,self.render_pass)
        
        self.paths['out_dir']="%s/%s/mantra/" % (self.envs['USER_PATH'],self.envs['USER'])
        
        # everything below relys on the version being set
        self.setVersion()
        
        mkfolder("%s/v%03d" % (self.paths['out_dir'],self.version))

        self.paths['pantry'] = _os.path.join(self.paths['out_dir'],"v%03d"%self.version,'.pantry')
                
        self.paths['scripts_path'] = '%s/scripts' % self.wd
        
        self.paths['img_path'] = "%s/v%03d/%s/" % (str(self.paths['out_dir']),int(self.version),'x'.join( map(str, self.res.values()) ) )

        self.setVersionWD()
Exemplo n.º 5
0
 def publishScene(self):
     ''' make a copy of the input nuke script in the working directory '''    
 
     nk_dir = '%s/nk' % self.wd
     
     mkfolder(nk_dir)
     
     self.nukescript = copyFile(self.nukescript,nk_dir)
Exemplo n.º 6
0
    def publishScene(self):
        ''' make a copy of the input maya file in the working directory '''

        mb_dir = '%s/mb' % self.wd

        mkfolder(mb_dir)

        self.scenefile = copyFile(self.scenefile, mb_dir)

        return self.scenefile
Exemplo n.º 7
0
    def setPaths(self):
        ''' Set the paths for pantry based resources (tdls,sdls,shadowmaps) '''

        self.paths['out_dir'] = ''

        if '3d_builds' in _os.path.abspath(self.envs['WORKSPACE_PATH']):
            self.paths['out_dir'] = "%s/render_tmp/%s/%s/%s/" % (
                self.envs['WORKSPACE_PATH'], self.camera.split(':')[-1],
                self.layer, self.render_pass)
        else:
            self.paths['out_dir'] = "%s/3d/render_tmp/%s/%s/%s/" % (
                self.envs['WORKSPACE_PATH'], self.camera.split(':')[-1],
                self.layer, self.render_pass)

        self.paths['pantry'] = '%(SHOW_PATH)s/3d/pantry/%(SHOT)s' % (self.envs)
        if self.updatedVersion == False:
            self.setVersion()
            self.updatedVersion = True
        if not _os.path.exists("%s/v%03d" %
                               (self.paths['out_dir'], self.version)):
            mkfolder("%s/v%03d" % (self.paths['out_dir'], self.version))

        self.paths['ass_path'] = '%s/ass' % self.wd

        self.paths['mb_path'] = '%s/mb' % self.wd

        self.paths['scripts_path'] = '%s/scripts' % self.wd

        self.paths['img_path'] = "%s/v%03d/%s/" % (str(
            self.paths['out_dir']), int(self.version), 'x'.join(
                map(str, self.res.values())))

        self.paths[
            'img_beauty_path'] = "%s/v%03d/%s/%s_masterLayer_lnh_v%03d.####.exr" % (
                str(self.paths['out_dir']), int(self.version), 'x'.join(
                    map(str, self.res.values())), self.asset, int(
                        self.version))

        if self.dailyOutput != 'True':
            qtBasepath = '%s/v%03d/turntable' % (self.paths['out_dir'],
                                                 int(self.version))
            self.paths['qt_path'] = '%s/%s_turntable_v%03d.mov' % (
                qtBasepath, self.asset, int(self.version))
        else:
            qtBasepath = _os.path.join(self.envs['SHOW_PATH'], 'dailies',
                                       self.envs['SCENE'], self.envs['SHOT'],
                                       self.discipline, 'internal',
                                       'v%03d' % self.version)
            self.paths['qt_path'] = '%s/%s_turntable_v%03d.mov' % (
                qtBasepath, self.asset, int(self.internalVersion))

        if not _os.path.exists(qtBasepath):
            _os.makedirs(qtBasepath)
Exemplo n.º 8
0
	def createQsubExecScript(self):
		''' 
			create the qsub submission script.
		'''
		
		
		exe="qsub -r y"
		
		if self.paused:
			exe+=" -h "
			
		args={'email':'-m a -M %[email protected]' % os.getenv('USER'),
		'jobname':self.name,
		'wd':self.wd,
		'render_script':self.scripts['render_script']['script'].name,
		'logs_path':self.paths['log_path'],
		'exe':exe,
		'CPUS':self.cpus}
					
		# Make logs directory
		
		if not os.path.isdir(self.paths['log_path']):
			mkfolder(self.paths['log_path'])
			
		
		
		script = '''#!/bin/bash
#
# Submision Script for %s
#			\n''' % (self.scenefile)
		
		
		if not self.email:
			args['email']=''
		
		script+="%(exe)s -l mem_free=4G  %(email)s -N %(jobname)s -o %(logs_path)s -wd %(wd)s %(render_script)s;\n" % (args)
		
		
		f = open(self.paths['scripts_path']+"/"+args['jobname'], 'w')
		f.write(script)
		f.close()
	
		os.chmod(self.paths['scripts_path']+"/"+args['jobname'], 0775)
		
		# assign this script to the main script name
		
		self.script=f
		
		return f
Exemplo n.º 9
0
	def createJobScript(self):
		'''
			Generate the job script for this submission to grid
		'''
		
		envs = ""
		
		for e in self.envs.keys():
			envs += "export %s=%s" % (e,self.envs[e])
		
		settings={'cmd':self.cmd,'envs':envs,'prescript':self.prescript}

		if not os.path.isdir(self.wd):
			mkfolder(self.wd)
	
		f = open(self.wd+"/mkdaily."+self.name+".render", 'w')
		
		f.write('''#!/bin/bash
#$ -S /bin/bash
#$ -j y
umask 0002

%(prescript)s

%(envs)s

cmd='%(cmd)s'

echo
echo $cmd
echo
exec $cmd

exitstatus=$?

if [ $exitstatus != 0 ];then
exit 100
fi

exit $exitstatus\n''' % (settings))
	
	
		f.close()

		self.scripts['cmd_script'] = {'script':f,'type':1,'name':'cmd'}
		
		return f
Exemplo n.º 10
0
    def createQsubExecScript(self):

        exe = "qsub -r y"

        if self.paused:
            exe += " -h "

        args = {
            'framerange': '%d-%d' % (self.start, self.end),
            'step': self.step,
            'email': '-m a -M %[email protected]' % os.getenv('USER'),
            'jobname': self.name,
            'wd': self.wd,
            'script': self.scripts['render_script']['script'].name,
            'logs': self.paths['log_path'],
            'exe': exe,
            'cpu': self.cpus
        }

        # Make logs directory

        if not os.path.isdir(self.paths['log_path']):
            mkfolder(self.paths['log_path'])

        if not self.email:
            args['email'] = ''

        script = '''#!/bin/bash
#
# Submision Script for %s
#			\n''' % (self.scenefile)

        script += "%(exe)s -l mem_free=4G -l maya_sw=%(cpu)s -q 3d.q -t %(framerange)s:%(step)s %(email)s -tc 50 -N maya_sw.%(jobname)s -wd %(wd)s -o %(logs)s %(script)s\n" % args

        f = open(self.paths['scripts_path'] + "/" + self.name, 'w')
        f.write(script)
        f.close()

        os.chmod(self.paths['scripts_path'] + "/" + self.name, 0775)

        self.script = f

        return self.script
Exemplo n.º 11
0
    def makeScripts(self):
        ''' Generate the render scripts and the qsub submission script '''

        print 'generating scripts in ... %s' % self.wd

        #if self.publishscene:

        if not os.path.isdir(self.paths['mb_path']):
            mkfolder(self.paths['mb_path'])

        publishedfile = "%s/%s" % (self.paths['mb_path'],
                                   os.path.basename(self.scenefile))

        if not os.path.isfile(publishedfile):
            print "Copying scene file ..."
            org_size = os.path.getsize(self.scenefile)
            copyFile(self.scenefile, self.paths['mb_path'])

        self.scenefile = publishedfile

        return self.createJobScript()
Exemplo n.º 12
0
    def setPaths(self):
        ''' Set the paths for pantry based resources (tdls,sdls,shadowmaps) '''

        if not 'out_dir' in self.paths:
            self.paths['out_dir'] = "%s/renders/%s/%s/" % (
                self.envs['USER_PATH'], self.layer, self.render_pass)

        # self.paths['pass_path']='%s/%s/%s/%s' % (self.paths['out_dir'],self.layer,self.render_pass,self.camera.split(':')[-1])

        self.setversion()

        self.paths['pantry'] = os.path.join(self.paths['out_dir'],
                                            "v%03d" % self.version, '.pantry')

        self.setWD(self.paths['pantry'])
        mkfolder(self.wd)

        self.paths['mb_path'] = '%s/mb' % self.wd
        self.paths['scripts_path'] = '%s/scripts' % self.wd

        if not 'img_path' in self.paths:
            self.paths['img_path'] = "v%03d/%s" % (int(self.version), 'x'.join(
                map(str, self.res.values())))

        if not self.combine_exr:

            self.paths[
                'img_path'] += "/<RenderPass>/%s_<RenderLayer>_<RenderPass>_lnf_v%03d" % (
                    self.envs['WORKSPACE'], self.version)
            self.paths[
                'img_name'] = "<RenderPass>/%s_<RenderLayer>_<RenderPass>_lnf_v%03d" % (
                    self.envs['WORKSPACE'], self.version)

        else:
            self.paths['img_path'] += "/%s_<RenderLayer>_lnf_v%03d" % (
                self.envs['WORKSPACE'], self.version)
            self.paths['img_name'] = "%s_lnf_v%03d" % (self.envs['WORKSPACE'],
                                                       self.version)
Exemplo n.º 13
0
    def createJobScript(self):
        '''
		Create a job script for an array task
		'''

        if self.frames != '%d-%d' % (self.start,
                                     self.end) and self.frames == '1-20':
            self.frames = '%d-%d' % (self.start, self.end)

        settings = {
            'runcommand': self.runcommand,
            'myappversion': self.myappversion,
            'SHOW': self.envs['SHOW'],
            'SHOW_PATH': self.envs['SHOW_PATH'],
            'SCENE': self.envs['SCENE'],
            'SCENE_PATH': self.envs['SCENE_PATH'],
            'SHOT': self.envs['SHOT'],
            'WORKSPACE_PATH': self.envs['WORKSPACE_PATH'],
            'render_cmd': '/path/to/app',
            'USER': self.user
        }

        # cerate the working directory if it doesn't exit

        if not os.path.isdir(self.wd):
            mkfolder(self.wd)

        #open up the render script that will get executed and add the contents

        f = open(self.wd + "/myapp." + self.name + ".render", 'w')

        f.write('''#!/bin/bash
#$ -S /bin/bash
#$ -j y
umask 0002

#set workspace

source ${SOFTWARE}/bluebolt/envset/workspace %(WORKSPACE_PATH)s

export MYAPP_VERSION=%(myappversion)s
echo umask :: `umask`
echo This Host ::: $HOSTNAME
echo User::: $USER
echo UNAME::: $UNAME
echo DIST::: $DIST
echo ARCH::: $ARCH
echo NUKE_VERSION::: $NUKE_VERSION

s=$SGE_TASK_ID
e=`echo $[$s+$SGE_TASK_STEPSIZE-1]`
if [ $e -ge $SGE_TASK_LAST ]; then
	e=$SGE_TASK_LAST;
fi

echo START :: $s
echo END :: $e

cmd="%(render_cmd)s -args ... -F $s-$e -x %(runcommand)s "

function this_task(){

echo
echo $cmd
echo
exec $cmd 
exitstatus=$?

if [ $exitstatus != 0 ];then
exit 100
fi

exit $exitstatus

}

eval this_task\n''' % (settings))

        f.close()

        # add this script to the render scripts dictionary
        '''
		'script' : script to executed
		'type' : 0 - redunant scripts (non-executable), 1 - single job, 2 - array job
		'name' : this job type name that will go at the start of this script
		-- optionals --
		'options' : any arguments that the submitter needs e.g resourses
		'frames' : a string containing the list of ranges to render in an array job
		'step' : the step size for the tasks in an array job
		'dep' : the 'name'(above) of the script this job script depends on 
			 and will wait to be completed before atrting
		'''

        self.scripts['render_script'] = {
            'script': f,
            'type': 2,
            'options': ' -l myapp=1 -tc 15 ',
            'name': 'myapp',
            'frames': '%s' % self.frames,
            'step': self.step
        }

        return f
Exemplo n.º 14
0
	def _createQsubExecScript(self):
		''' 
			create the qsub submission script.
		'''
		
		
		exe="qsub -r y"
		
		if self.paused:
			exe+=" -h "
		
		
		if self.slices>1:
			self.step=1
			
			
		script = '''#!/bin/bash
	#
	# Submision Script for %s
	#			\n''' % (self.scenefile)
			
		for framerange in self.frames.split(','):
			
			
			args={'framerange':'%s-%s' % (framerange.split('-')[0],framerange.split('-')[-1]),
			'step':self.step,
			'email':'-m a -M %[email protected]' % os.getenv('USER'),
			'jobname':self.name,
			'wd':self.wd,
			'max_slots':self.max_slots,
			'queue':self.queue,
			'rib_script':self.scripts['rib_script']['script'].name,
			'render_script':self.scripts['render_script']['script'].name,
			'logs_path':self.paths['log_path'],
			'exe':exe,
			'CPUS':self.cpus}
			
			args['taskrange']=args['framerange']
			args['rendertasks']=args['taskrange']
			args['pre_ren_step']=args['step']
			
			if self.slices>1:
				args['pre_ren_step']=self.slices
				args['taskrange']='1-%d' % (self.slices)
				args['rendertasks']='1-%d' % self.slices
				
				
				
			
			if self.preflight:
				args['preflight_script']=self.scripts['preflight_script']['script'].name
				
			if self.bake:
				args['bake_script']=self.scripts['bake_script']['script'].name
			
			
			if self.cleanup:
				args['cleanup_script']=self.scripts['cleanup_script']['script'].name
				
			# Make logs directory
			
			if not os.path.isdir(self.paths['log_path']):
				mkfolder(self.paths['log_path'])
				
			
			
			
			
			if not self.email:
				args['email']=''
			
			args['rib_wait'] = ''		
			
			if self.preflight:
				
				script+="%(exe)s -l mem_free=4G -l dl=1 -q %(queue)s  -t %(taskrange)s:%(pre_ren_step)d -tc %(max_slots)d %(email)s -N preflight.%(jobname)s -o %(logs_path)s -wd %(wd)s %(preflight_script)s;\n" % (args)
				args['rib_wait']='-hold_jid_ad preflight.%(jobname)s' % (args)
				
				
				
			if self.bake:
				args['bake_wait']=''
				if self.preflight:
					args['bake_wait']='-hold_jid_ad preflight.%(jobname)s' % (args)
					
				script+="%(exe)s -l mem_free=4G -l dl=1 -q %(queue)s -t %(taskrange)s:%(pre_ren_step)d -tc %(max_slots)d %(email)s %(bake_wait)s -N bake.%(jobname)s -o %(logs_path)s -wd %(wd)s %(bake_script)s;\n" % (args)
				args['rib_wait']='-hold_jid_ad bake.%(jobname)s' % (args)
				
			script+="%(exe)s -l mem_free=4G -l dl=1 -q %(queue)s -t %(rendertasks)s:%(step)d -tc %(max_slots)d %(email)s %(rib_wait)s -N ribgen.%(jobname)s -o %(logs_path)s -wd %(wd)s %(rib_script)s;\n" % (args)
			
			script+="%(exe)s -l mem_free=4G -pe render %(CPUS)s -l dl=1 -q %(queue)s  -t %(rendertasks)s:%(step)d -tc %(max_slots)d %(email)s -hold_jid_ad ribgen.%(jobname)s -N delight.%(jobname)s -o %(logs_path)s -wd %(wd)s %(render_script)s;\n" % (args)
			
			
			if self.cleanup:
				script+="%(exe)s -q %(queue)s -t %(rendertasks)s:%(step)d -tc %(max_slots)d -hold_jid_ad delight.%(jobname)s -N cleanup.%(jobname)s -o %(logs_path)s -wd %(wd)s %(cleanup_script)s;\n" % (args)
			
		f = open(self.paths['scripts_path']+"/"+args['jobname'], 'w')
		f.write(script)
		f.close()
	
		os.chmod(self.paths['scripts_path']+"/"+args['jobname'], 0775)
		
		# assign this script to the main script name
		
		self.script=f
		
		return f
Exemplo n.º 15
0
    def createJobScript(self):
        ''' Generate the bash script  for rendering '''

        if not _os.path.isdir(self.paths['scripts_path']):
            mkfolder(self.paths['scripts_path'])

        # do the publish

        if self.publish:
            self.publishScene()

        # settings #

        settings = {
            'scenefile':
            self.scenefile,
            'wd':
            self.wd,
            'maya':
            self.maya_version,
            'camera':
            self.camera,
            'render_cmd':
            self.render_cmd,
            'mayaproject':
            '%s/user/%s/maya' %
            (self.envs['WORKSPACE_PATH'], self.envs['USER']),
            'args':
            self.args,
            'slice':
            self.slices > 1,
            'num_slices':
            self.slices,
            'CPUS':
            self.cpus,
            'WORKSPACE_PATH':
            self.envs['WORKSPACE_PATH'],
            'task_header':
            ' '.join((self.name, self.date, self.scenefile))
        }

        settings['envs'] = ''
        # simple loop over the envs in the self.envs dictionary to add any envs to the render script
        for e in self.envs.keys():
            settings['envs'] += 'export %s=%s;\n' % (e, self.envs[e])

        settings['taskscript'] = '''
s=$SGE_TASK_ID
e=`echo $[$s+$SGE_TASK_STEPSIZE-1]`
if [ $e -ge $SGE_TASK_LAST ]; then
    e=$SGE_TASK_LAST;
fi


echo START :: $s
echo END :: $e

'''

        #Slicing settings
        if self.slices > 1:
            settings['taskscript'] = '''

s=%d
e=%d

echo START :: $s
echo END :: $e

export SLICE="true"
echo SLICE :: $SLICE

export SLICE_PADDED=`printf "%%02d" $SGE_TASK_ID`

            ''' % (self.start, self.start)

        #Generate preflight BASH script
        render_script = open(
            self.paths['scripts_path'] + "/" + self.label +
            ".%s" % self.dt.strftime('%Y%m%d%H%M%S') + ".sh", 'w')

        render_script.write('''#!/bin/bash
        
#
# MAYA Batch job - %(task_header)s
#    


#$ -S /bin/bash
#$ -j y
#$ -l maya=1

umask 0002

#set workspace

source ${SOFTWARE}/bluebolt/config/workspace.env

eval workspace -no-hi %(WORKSPACE_PATH)s

export MAYA_APP_DIR=${TMPDIR}/maya;
export MAYA_VERSION=%(maya)s;
export MAYA_MAJOR_VERSION=%(maya)s;
export MAYA_LOCATION=$SOFTWARE/maya/$UNAME.$DIST.$ARCH/%(maya)s;

%(envs)s

echo umask :: `umask`
echo This Host ::: $HOSTNAME
echo User::: $USER
echo UNAME::: $UNAME
echo DIST::: $DIST
echo ARCH::: $ARCH

unset SLICE
unset SLICE_PADDED

%(taskscript)s

export START=$s
export END=$e

function this_task(){

cmd="%(render_cmd)s -batch -proj %(mayaproject)s -file %(scenefile)s %(args)s"
echo $cmd
#Run it
time $cmd

exitstatus=$?

if [ $exitstatus != 0 ];then
return 100
fi

return $exitstatus

}

eval this_task

''' % (settings))

        render_script.close()

        self.script = render_script.name

        return render_script
Exemplo n.º 16
0
	def createAOVMelScript(self):
		''' Create the MEL script that will set up the aovs for the render '''
				
		# make scripts path if it doesn't exists #
		
		if not os.path.isdir(self.paths['scripts_path']):
			mkfolder(self.paths['scripts_path'])
			
					
		outputPath = "%s" % (self.paths['img_path'])
		
		self.res_path="%s/v%03d/%s" % (self.paths['out_dir'],
								self.version,
								'x'.join(self.res.values()))
		
		args={'width':self.res['width'],
		'height':self.res['height'],
		'rib_path':'%s/%s_' % (self.paths['rib_path'],self.prefix),
		'img_path':self.paths['img_path'],
		'aov_str':'',
		'netcache_dir':self.netcache_dir,
		'netcache_size':self.netcache_size}
		
		
		if not os.path.isdir(self.paths['scripts_path']):
			mkfolder(self.paths['scripts_path'])
		
		padded_version = "v%03d" % self.version
		
		'''	
		aovs_list = dict()
				
		print self.aovs
		for output in self.aovs.keys():
			print output
			if output == "":
				continue
			else :
				for aov in self.aovs[output]['aovs']:
					print aov
					if aov == "":
						continue
					else:
						aovs_list[output].append(aov)
		
		
		aov_string='","'.join(aovs_list)
		'''
#		
#		aov_array_s = 'string $aovs[]={"%s"};\n' % aov_string
#		
#		aov_cmd=aov_array_s
		
		aov_cmd='''	
// 
//
//'''
		
		'''
		#	Set the old ones to the correct path and file type (even if they arn't renderable)		
		'''
				
		#self.delight_major_version=float('%s.%s' % (self.delightversion.split('.')[0],self.delightversion.split('.')[1]))
		#self.delight_build_version=float(self.delightversion.split('.')[2])
		
		args['i_output']=0
		
		args['aov_str']=''
		
		for output in self.aovs.keys():
		
			self.paths['img_path'] ="%s/v%03d/%s/%s/%s_%s_lnf_v%03d" % (self.paths['out_dir'],
														self.version,
														'x'.join(self.res.values()),
														output.lower(),
														self.envs['SHOT'],
														self.layer,
														self.version)
			
			
			args['img_path']=self.paths['img_path']
			args['aov_string']=','.join(self.aovs[output]['aovs'])
			args['output']=output
			
			if self.aovs[output].has_key('half_float'):
				args['half']=int(self.aovs[output]['half_float'])
			else:
				args['half']=1
				
			if self.aovs[output].has_key('premult'):
				args['premult']=int(self.aovs[output]['half_float'])
			else:
				args['premult']=1
				
			
			args['aov_str']+='''	
	print ("Adding : \\"%(output)s\\"\\n");
	setAttr -type "string" ($render_pass+".displayOutputVariables[%(i_output)d]") "%(aov_string)s";
	setAttr -type "string" ($render_pass+".displayDrivers[%(i_output)d]") "exr";
	setAttr -type "string" ($render_pass+".displayFilenames[%(i_output)d]") ("%(img_path)s"+$slice_str+".#.<ext>");
	setAttr ($render_pass+".displayQuantizeZeros[%(i_output)d]") 0;
	setAttr ($render_pass+".displayQuantizeOnes[%(i_output)d]") 0;
	setAttr ($render_pass+".displayQuantizeMins[%(i_output)d]") 0;
	setAttr ($render_pass+".displayQuantizeMaxs[%(i_output)d]") 0;
	setAttr ($render_pass+".displayQuantizeDithers[%(i_output)d]") 0;
	setAttr ($render_pass+".displayHalfFloats[%(i_output)d]") %(half)d;	
	setAttr ($render_pass+".displayRenderables[%(i_output)d]") 1;
	setAttr ($render_pass+".displayAssociateAlphas[%(i_output)d]") %(premult)d;
			''' % (args)
			
			
			# check if we have edgedetection involved
			# if so add the edge detection to it
			
			if self.aovs[output].has_key('edge_detection'):
				ed_EdgeVar=self.aovs[output]['edge_detection']
				
				edge_args={'ed_EdgeVar':ed_EdgeVar,'i_output':args['i_output']}
				
				args['aov_str']+='''
	setAttr -type "string" ($render_pass+".displayEdgeVarNames[%(i_output)d]") "%(ed_EdgeVar)s";
	setAttr ($render_pass+".displayEdgeEnables[%(i_output)d]") 1;
	setAttr ($render_pass+".displayEdgeColors[%(i_output)d]") -type double3 1 1 1 ;
	setAttr ($render_pass+".displayEdgeFilterWidths[%(i_output)d]") 1;
	''' % edge_args 
	
			else:
				args['aov_str']+='''
	setAttr ($render_pass+".displayEdgeEnables[%(i_output)d]") 0;
	''' % args
				
				
			args['i_output'] += 1
		
		aov_cmd+='''
	
//import pymel.core
python("from pymel.core import *");

//Set the resolution	

setAttr ($render_pass+".connectToRenderGlobals") 0;

if (python("PyNode('"+$render_pass+".resolutionX').isLocked()"))
	python("PyNode('"+$render_pass+".resolutionX').unlock()");
	
if (python("PyNode('"+$render_pass+".resolutionX').isConnected()"))
	python("PyNode('"+$render_pass+".resolutionX').disconnect()");
	

if (python("PyNode('"+$render_pass+".resolutionY').isLocked()"))
	python("PyNode('"+$render_pass+".resolutionY').unlock()");
	
if (python("PyNode('"+$render_pass+".resolutionY').isConnected()"))
	python("PyNode('"+$render_pass+".resolutionY').disconnect()");
	
setAttr ($render_pass+".resolutionX") %(width)s;
setAttr ($render_pass+".resolutionY") %(height)s;
''' % args

		if self.netcache_enable:
			aov_cmd+='''

// Set up Net Cache

setAttr ($render_pass+".useNetCache") 1;
setAttr -type "string" ($render_pass+".netCacheDir") "%(netcache_dir)s";
setAttr ($render_pass+".netCacheSize") %(netcache_size)d;

''' % args

		aov_cmd+='''
// detect slicing

$slice=getenv("SLICE");

string $slice_str;

if ($slice != ""){
	
	

	$slice_str = "_$SLICE_PADDED";
	print($slice_str+"\\n");
}


$start = getenv("START");
$end = getenv("END");

// set the riboutput path 

setAttr -type "string" ($render_pass+".ribFilename") ("%(rib_path)s"+$start+"-"+$end+$slice_str+".rib");

// set secondarys on 
setAttr ($render_pass+".renderSecondaryDisplays") 1;

$numDisplays=`getAttr -s ($render_pass+".displayDrivers")`;
for ($d=0;$d<$numDisplays;$d++)
{
	setAttr ($render_pass+\".displayRenderables["+$d+"]") 0;
}
print ($render_pass+"\\n");
%(aov_str)s''' % (args)
		
		
		
		
		mel_script_fn = "%s/%s_aov.mel" % (self.paths['scripts_path'],self.prefix)
		
		mel_script = file(mel_script_fn,'w')
		mel_script.write(aov_cmd)
		mel_script.close()
	
		return mel_script_fn
Exemplo n.º 17
0
	def createJobScript(self):	
		'''
		Create a job script for an array task
		'''
		
		
		if self.frames != '%d-%d' % (self.start,self.end) and self.frames == '1-20':
			self.frames='%d-%d' % (self.start,self.end)
		
		
		settings={'runcommand':self.runcommand,
		'myappversion':self.myappversion,
		'SHOW':self.envs['SHOW'],
		'SHOW_PATH':self.envs['SHOW_PATH'],
		'SCENE':self.envs['SCENE'],
		'SCENE_PATH':self.envs['SCENE_PATH'],
		'SHOT':self.envs['SHOT'],
		'WORKSPACE_PATH':self.envs['WORKSPACE_PATH'],
		'render_cmd':'/path/to/app',
		'USER':self.user}

		# cerate the working directory if it doesn't exit

		if not os.path.isdir(self.wd):
			mkfolder(self.wd)
	
		#open up the render script that will get executed and add the contents
			
		f = open(self.wd+"/myapp."+self.name+".render", 'w')
		
		f.write('''#!/bin/bash
#$ -S /bin/bash
#$ -j y
umask 0002

#set workspace

source ${SOFTWARE}/bluebolt/envset/workspace %(WORKSPACE_PATH)s

export MYAPP_VERSION=%(myappversion)s
echo umask :: `umask`
echo This Host ::: $HOSTNAME
echo User::: $USER
echo UNAME::: $UNAME
echo DIST::: $DIST
echo ARCH::: $ARCH
echo NUKE_VERSION::: $NUKE_VERSION

s=$SGE_TASK_ID
e=`echo $[$s+$SGE_TASK_STEPSIZE-1]`
if [ $e -ge $SGE_TASK_LAST ]; then
	e=$SGE_TASK_LAST;
fi

echo START :: $s
echo END :: $e

cmd="%(render_cmd)s -args ... -F $s-$e -x %(runcommand)s "

function this_task(){

echo
echo $cmd
echo
exec $cmd 
exitstatus=$?

if [ $exitstatus != 0 ];then
exit 100
fi

exit $exitstatus

}

eval this_task\n''' % (settings))
	
	
		f.close()		
		
		# add this script to the render scripts dictionary

		'''
		'script' : script to executed
		'type' : 0 - redunant scripts (non-executable), 1 - single job, 2 - array job
		'name' : this job type name that will go at the start of this script
		-- optionals --
		'options' : any arguments that the submitter needs e.g resourses
		'frames' : a string containing the list of ranges to render in an array job
		'step' : the step size for the tasks in an array job
		'dep' : the 'name'(above) of the script this job script depends on 
			 and will wait to be completed before atrting
		'''

		self.scripts['render_script'] =  {'script':f,'type':2,'options':' -l myapp=1 -tc 15 ','name':'myapp','frames':'%s' % self.frames,'step':self.step}
		
		return f
Exemplo n.º 18
0
    def createJobScript(self):
        '''
            Generate the job script for this submission to grid
        '''

        envs = ""

        for e, v in self.envs.items():
            envs += "export %s=%s;echo %s=${%s};\n" % (e, v, e, e)

        settings = {
            'cmd': self.cmd,
            'envs': envs,
            'prescript': self.prescript,
            'postscript': self.postscript,
            'host_ip': self.submit_host,
            'host_port': self.portid
        }

        if not _os.path.isdir(self.paths['scripts_path']):
            mkfolder(self.paths['scripts_path'])

        f = open(
            self.paths['scripts_path'] + "/" + self.label +
            ".%s" % self.dt.strftime('%Y%m%d%H%M%S') + ".sh", 'w')

        f.write('''#!/bin/bash
#$ -S /bin/bash
#$ -j y
umask 0002

echo "HOST -> $HOSTNAME"
echo "DATE ->" `date`

%(prescript)s

%(envs)s

#Run it
function this_task(){

cmd="%(cmd)s"
echo $cmd

time eval $cmd

exitstatus=$?

if [ $exitstatus != 0 ];then
return 100
fi

return $exitstatus

}

eval this_task

%(postscript)s

# TODO: try and send signal to original host that task was complete



''' % (settings))

        f.close()

        self.scripts['cmd_script'] = {
            'script': f.name,
            'type': 1,
            'name': 'cmd'
        }

        self.script = f.name

        return f
Exemplo n.º 19
0
    def publishScene(self):
        ''' make a copy of the input maya file in the working directory '''

        mkfolder(self.paths["mb_path"])

        self.scenefile = copyFile(self.scenefile, self.paths["mb_path"])
Exemplo n.º 20
0
    def createJobScript(self):
        '''
			Generate the job script for this submission to grid
		'''

        #construct the mkdaily command based on self.vid (versionid) being set

        cmd = ''

        if not self.vid:  #create the mkdaily command from the other arguments
            '''	
			self.art='ashley-r'	#artist name shotgun username
			self.dpx=False         	#create dpx slate and sequence
			self.dsc='comp'   	#discipline default "Comp"
			self.dt='bluebolt'	#'bluebolt' (internal) default or 'client'
			self.fmt='mov'		#output format: dpx exr jpg tif
			self.isf=1001 
			self.ief=1100
			self.if=''		#path to source images
			self.sn=''     		#slate note
			
			self.log=None        	#not used kept for compatability reasons
			self.of=None   		#base path to destination images,
			self.osf=None		#output start frame
			self.oef=None  		#output end frame
			self.scl=1           	#scale of something...
			self.slo=False       	#Don't render a slate
			self.ush=True  		#write to the database. Default: True
			self.ver=1		#version number e.g. 001
			
			self.vid=None          	#version id (shotgun version id ) e.g 1654 if this is set use 'get_mkdaily_cmd' instead
			
			self.vnm='new_version'  #version name
			self.t=False            #thumbnail only
			'''

            #set up the string flags

            if self.frames != '%d-%d' % (self.start,
                                         self.end) and self.frames == '0-0':
                self.frames = '%d-%d' % (self.start, self.end)

            elif self.frames != '0-0':
                frames_split = self.frames.split(',')[0].split('-')

                if len(frames_split) == 2:
                    self.start, self.end = frames_split

            framerange = '--isf=%s --ief=%s' % (self.start, self.end)

            log_str = ''
            if self.log != None:
                log_str = '--log=%s' % self.log

            of_str = ''
            if self.of != None:
                of_str = '--of=%s' % self.of

            ouframerange = ''
            if self.osf != None and self.oef != None:
                ouframerange = '--osf=%s --oef=%s' % (self.osf, self.oef)

            scl_str = ''
            if self.scl != 1.0:
                scl_str = '--scl=%f' % self.scl

            t_str = ''
            if self.t:
                t_str = '-t'

            flags = {
                'dt': self.dt,
                'dpx': self.dpx,
                'vnm': self.vnm,
                'ver': self.ver,
                'dsc': self.dsc,
                'inf': self.inf,
                'framerange': framerange,
                'art': self.art,
                'sn': self.sn,
                'log': log_str,
                'of': of_str,
                'outframerange': ouframerange,
                'scl': scl_str,
                'slo': self.slo,
                'ush': self.ush,
                't': t_str
            }

            args = '--dt=%(dt)s --dpx=%(dpx)s --vnm=%(vnm)s --ver=%(ver)03d '\
            '--dsc=%(dsc)s --if=%(inf)s %(framerange)s --art=%(art)s --sn="%(sn)s"'\
            '%(log)s %(of)s %(outframerange)s %(scl)s --slo=%(slo)s --ush=%(ush)s %(t)s' % (flags)

            cmd = 'mkdaily %s' % args
        else:
            # generate command from get_mkdaily_cmd vid

            get_mkdaily_cmd_args = {'client': 'cl', 'bluebolt': ''}
            md_args = [
                '/software/wrappers/get_mkdaily_cmd',
                str(self.vid), get_mkdaily_cmd_args[self.dt]
            ]

            if self.dpx:
                md_args.append('dpx')

            cmd_bin = Popen(md_args, stdout=PIPE)
            cmd = cmd_bin.communicate()[0].strip()
            cmd_bin.stdout.close()

        settings = {
            'mkdaily': self.mkdaily_version,
            'SHOW': self.envs['SHOW'],
            'SHOW_PATH': self.envs['SHOW_PATH'],
            'SCENE': self.envs['SCENE'],
            'SCENE_PATH': self.envs['SCENE_PATH'],
            'SHOT': self.envs['SHOT'],
            'WORKSPACE_PATH': self.envs['WORKSPACE_PATH'],
            'cmd': cmd,
            'USER': self.user
        }

        if not os.path.isdir(self.wd):
            mkfolder(self.wd)

        f = open(self.wd + "/mkdaily." + self.name + ".render", 'w')

        f.write('''#!/bin/bash
#$ -S /bin/bash
#$ -j y
umask 0002

#set workspace

source /software/bluebolt/envset/workspace %(WORKSPACE_PATH)s

export MKDAILY_VERSION=%(mkdaily)s
echo umask :: `umask`
echo This Host ::: $HOSTNAME
echo User::: $USER
echo UNAME::: $UNAME
echo DIST::: $DIST
echo ARCH::: $ARCH
echo MKDAILY_VERSION::: $MKDAILY_VERSION


cmd='%(cmd)s'

echo
echo $cmd
echo
exec $cmd

exitstatus=$?

if [ $exitstatus != 0 ];then
exit 100
fi

exit $exitstatus\n''' % (settings))

        f.close()

        # priorotize non development dailies over dev ones
        options = ' -l mkdaily=1'

        if not self.envs['SHOW'].endswith('_dev'):
            options += '-p -100'

        self.scripts['render_script'] = {
            'script': f,
            'type': 1,
            'options': options,
            'name': 'mkdaily',
            'frames': '%s' % self.frames,
            'step': self.step
        }

        return f