def execute(self, app, outputs, **kwargs): ''' app: main class app outputs: list of dicts with the following keys: jobname: String Jobname from UI. priority: Int Priority value from UI. start: Int Start frame from UI. end: Int End frame from UI. limit: String Limit from UI. work_file: String Path to work file. output: Dict Dictionary with all data from the outputs: name: String Name of output in the environment. tank_type: String Tank type specified in the environment. ''' print 'Post Render Hook!' self.app = app self.outputs = outputs print 'app:' print self.app #print self.app.sgtk.templates["maya_shot_work"] print 'outputs:' for output in self.outputs: filePath = nuke.root()['name'].value() name = output["jobname"] priority = output["priority"] start = output["start"] end = output["end"] inputFilepath = output["work_file"] pluginArgs = [''] submitArgs = ['Comment=Shotgun Publish submit'] shotgunContext = self.parent.context #getting fields for version shot_temp = self.parent.sgtk.templates["nuke_shot_work"] shotgunFields = shot_temp.get_fields(filePath) #getting output path area_temp = self.parent.sgtk.templates['nuke_shot_render_area'] outputPath = area_temp.apply_fields(shotgunFields).replace( '\\', '/') #getting output fields render_temp = self.parent.sgtk.templates['nuke_shot_render_exr'] outputFiles = render_temp.apply_fields(shotgunFields) outputFields = render_temp.get_fields(outputFiles) #clunky code to replace seq format with ? cmd = '' maxCount = int( outputFiles.split('%')[-1].split('.')[0].replace('d', '')) for count in xrange(0, maxCount): cmd += '?' path = outputFiles.split('%')[0][0:-1] ext = outputFiles.split('%')[-1].split('.')[-1] outputFile = '.'.join([path, cmd, ext]).replace('\\', '/') outputFiles = [outputFile] #getting login for user and replacing with user in shotgunContext shotgunUser = sgtk.util.get_current_user(self.parent.sgtk) #creating the folders for rendering for outputfile in outputFiles: dirpath = os.path.dirname(outputfile) if not os.path.exists(dirpath): os.makedirs(dirpath) #submit to deadline cdu.submit('nuke', name, start, end, inputFilepath, outputPath, outputFiles, pluginArgs, submitArgs, shotgunContext=shotgunContext, shotgunFields=shotgunFields, shotgunUser=shotgunUser, limit=output['limit'], priority=output['priority'])
def _arnold_render(self, output): print 'Rendering Arnold!' pluginArgs = [''] submitArgs = ['Comment=Shotgun Publish submit'] shotgunContext = self.app.context #getting fields for version shot_temp = self.app.sgtk.templates["maya_shot_work"] shotgunFields = shot_temp.get_fields(output['work_file']) #getting output path area_temp = self.parent.sgtk.templates['maya_shot_render_area'] outputPath = area_temp.apply_fields(shotgunFields).replace('\\', '/') #getting ass file path area_temp = self.parent.sgtk.templates['maya_ass_export'] inputFilePath = area_temp.apply_fields(shotgunFields).replace( '\\', '/') % 1 inputFiles = [] for layer in cmds.ls(type='renderLayer'): #discarding referenced layers if ':' not in layer: #checking whether layer needs to be rendered if cmds.getAttr(layer + '.renderable') == 1: if layer == 'defaultRenderLayer': layer = 'masterLayer' #hardcoded replace of output['name'] string--- p = inputFilePath.replace('/data/', '/data/%s/' % layer) inputFiles.append(p) #getting output fields render_temp = self.parent.sgtk.templates['maya_shot_render'] outputFiles = render_temp.apply_fields(shotgunFields) outputFields = render_temp.get_fields(outputFiles) #replacing output['name'] with file output['name'] outputFields['name'] = '.'.join( output['work_file'].split('/')[-1].split('.')[0:-2]) #generate outputFiles shotgunFiles = render_temp.apply_fields(outputFields) outputFiles = [] for layer in cmds.ls(type='renderLayer'): #discarding referenced layers if ':' not in layer: #checking whether layer needs to be rendered if cmds.getAttr(layer + '.renderable') == 1: if layer == 'defaultRenderLayer': layer = 'masterLayer' #clunky code to replace seq format with ? cmd = '' maxCount = int( shotgunFiles.split('%')[-1].split('.')[0].replace( 'd', '')) for count in xrange(0, maxCount): cmd += '?' path = shotgunFiles.split('%')[0][0:-1] ext = shotgunFiles.split('%')[-1].split('.')[-1] outputFile = '.'.join([path, cmd, ext]).replace('\\', '/') #adding renderlayer to outputfiles filename = os.path.basename(outputFile) dirpath = os.path.dirname(outputFile) outputFiles.append( os.path.join(dirpath, layer + '_' + filename)) #adding renderlayer to shotgunfiles filename = os.path.basename(shotgunFiles) dirpath = os.path.dirname(shotgunFiles) #getting login for user and replacing with user in shotgunContext shotgunUser = sgtk.util.get_current_user(self.app.sgtk) #creating the folders for rendering for outputfile in outputFiles: dirpath = os.path.dirname(outputfile) if not os.path.exists(dirpath): os.makedirs(dirpath) #submit to deadline exportId = cdu.submit('arnoldExport', output['jobname'], output['start'], output['end'], output['work_file'], outputPath, [outputFiles[0]], ['ProjectPath=%s' % outputPath], submitArgs, shotgunContext='', shotgunFields='', shotgunUser='', mayaGUI=True, limit=output['limit'], priority=output['priority']) for f in inputFiles: count = inputFiles.index(f) #generate jobname layer = f.split('/')[-2] jobname = output['jobname'] + '.' + layer #execute deadline submittal cdu.submit('arnold', jobname, output['start'], output['end'], f, outputPath, [outputFiles[count]], pluginArgs, submitArgs=['JobDependencies=%s' % exportId], shotgunContext=shotgunContext, shotgunFields=shotgunFields, shotgunUser=shotgunUser, mayaGUI=True, priority=output['priority'])
def _network_render(self, item, output, work_template, primary_publish_path, sg_task, comment, thumbnail_path, progress_cb): filePath=nuke.root()['name'].value() name=os.path.basename(filePath) start=int(nuke.root()['first_frame'].value()) end=int(nuke.root()['last_frame'].value()) inputFilepath=filePath pluginArgs=[''] submitArgs=['Comment=Shotgun Publish submit'] shotgunContext=self.parent.context #getting fields for version shot_temp=self.parent.sgtk.templates["nuke_shot_work"] shotgunFields=shot_temp.get_fields(filePath) #getting output path area_temp=self.parent.sgtk.templates['nuke_shot_render_area'] outputPath=area_temp.apply_fields(shotgunFields).replace('\\','/') #getting output fields render_temp=self.parent.sgtk.templates['nuke_shot_render_exr'] outputFiles=render_temp.apply_fields(shotgunFields) outputFields=render_temp.get_fields(outputFiles) #setting output publishFiles=[outputFiles] #clunky code to replace seq format with ? cmd='' maxCount=int(outputFiles.split('%')[-1].split('.')[0].replace('d','')) for count in xrange(0,maxCount): cmd+='?' path=outputFiles.split('%')[0][0:-1] ext=outputFiles.split('%')[-1].split('.')[-1] outputFile='.'.join([path,cmd,ext]).replace('\\','/') outputFiles=[outputFile] #getting login for user and replacing with user in shotgunContext shotgunUser=sgtk.util.get_current_user(self.parent.sgtk) #creating the folders for rendering for outputfile in outputFiles: dirpath=os.path.dirname(outputfile) if not os.path.exists(dirpath): os.makedirs(dirpath) #submit to deadline cdu.submit('nuke', name, start, end, inputFilepath, outputPath, outputFiles, pluginArgs, submitArgs, shotgunContext=shotgunContext, shotgunFields=shotgunFields,shotgunUser=shotgunUser) # Finally, register this publish with Shotgun tank_type='Comp Render' name=item["name"] for outputfile in publishFiles: self._register_publish(outputfile, name, sg_task, shotgunFields['version'], tank_type, comment, thumbnail_path, [primary_publish_path])
def execute(self,app,outputs, **kwargs): ''' app: main class app outputs: list of dicts with the following keys: jobname: String Jobname from UI. priority: Int Priority value from UI. start: Int Start frame from UI. end: Int End frame from UI. limit: String Limit from UI. work_file: String Path to work file. output: Dict Dictionary with all data from the outputs: name: String Name of output in the environment. tank_type: String Tank type specified in the environment. ''' print 'Post Render Hook!' self.app=app self.outputs=outputs print 'app:' print self.app #print self.app.sgtk.templates["maya_shot_work"] print 'outputs:' for output in self.outputs: filePath=nuke.root()['name'].value() name = output["jobname"] priority = output["priority"] start=output["start"] end=output["end"] inputFilepath=output["work_file"] pluginArgs=[''] submitArgs=['Comment=Shotgun Publish submit'] shotgunContext=self.parent.context #getting fields for version shot_temp=self.parent.sgtk.templates["nuke_shot_work"] shotgunFields=shot_temp.get_fields(filePath) #getting output path area_temp=self.parent.sgtk.templates['nuke_shot_render_area'] outputPath=area_temp.apply_fields(shotgunFields).replace('\\','/') #getting output fields render_temp=self.parent.sgtk.templates['nuke_shot_render_exr'] outputFiles=render_temp.apply_fields(shotgunFields) outputFields=render_temp.get_fields(outputFiles) #clunky code to replace seq format with ? cmd='' maxCount=int(outputFiles.split('%')[-1].split('.')[0].replace('d','')) for count in xrange(0,maxCount): cmd+='?' path=outputFiles.split('%')[0][0:-1] ext=outputFiles.split('%')[-1].split('.')[-1] outputFile='.'.join([path,cmd,ext]).replace('\\','/') outputFiles=[outputFile] #getting login for user and replacing with user in shotgunContext shotgunUser=sgtk.util.get_current_user(self.parent.sgtk) #creating the folders for rendering for outputfile in outputFiles: dirpath=os.path.dirname(outputfile) if not os.path.exists(dirpath): os.makedirs(dirpath) #submit to deadline cdu.submit('nuke', name, start, end, inputFilepath, outputPath, outputFiles, pluginArgs, submitArgs, shotgunContext=shotgunContext, shotgunFields=shotgunFields,shotgunUser=shotgunUser, limit=output['limit'],priority=output['priority'])
def _arnold_render(self, item, output, work_template, primary_publish_path, sg_task, comment, thumbnail_path, progress_cb): filePath = cmds.file(q=True, sn=True) name = os.path.basename(filePath) start = int(cmds.getAttr('defaultRenderGlobals.startFrame')) end = int(cmds.getAttr('defaultRenderGlobals.endFrame')) pluginArgs = [''] submitArgs = ['Comment=Shotgun Publish submit'] shotgunContext = self.parent.context #getting fields for version shot_temp = self.parent.sgtk.templates["maya_shot_work"] shotgunFields = shot_temp.get_fields(filePath) #getting output path area_temp = self.parent.sgtk.templates['maya_shot_render_area'] outputPath = area_temp.apply_fields(shotgunFields).replace('\\', '/') #getting ass file path area_temp = self.parent.sgtk.templates['maya_ass_export'] inputFilepath = area_temp.apply_fields(shotgunFields).replace( '\\', '/') #getting ass file path area_temp = self.parent.sgtk.templates['maya_shot_publish'] mayaFile = area_temp.apply_fields(shotgunFields).replace('\\', '/') #hardcoded replace of sequence string--- inputFilepath = inputFilepath.replace('%05d', str(start).zfill(5)) inputFiles = [] for layer in cmds.ls(type='renderLayer'): #discarding referenced layers if ':' not in layer: #checking whether layer needs to be rendered if cmds.getAttr(layer + '.renderable') == 1: if layer == 'defaultRenderLayer': layer = 'masterLayer' #hardcoded replace of name string--- p = inputFilepath.replace('/data/', '/data/%s/' % layer) inputFiles.append(p) #getting output fields render_temp = self.parent.sgtk.templates['maya_shot_render'] outputFiles = render_temp.apply_fields(shotgunFields) outputFields = render_temp.get_fields(outputFiles) #replacing name with file name outputFields['name'] = '.'.join( filePath.split('/')[-1].split('.')[0:-2]) #generate outputFiles shotgunFiles = render_temp.apply_fields(outputFields) outputFiles = [] publishFiles = [] for layer in cmds.ls(type='renderLayer'): #discarding referenced layers if ':' not in layer: #checking whether layer needs to be rendered if cmds.getAttr(layer + '.renderable') == 1: if layer == 'defaultRenderLayer': layer = 'masterLayer' #clunky code to replace seq format with ? cmd = '' maxCount = int( shotgunFiles.split('%')[-1].split('.')[0].replace( 'd', '')) for count in xrange(0, maxCount): cmd += '?' path = shotgunFiles.split('%')[0][0:-1] ext = shotgunFiles.split('%')[-1].split('.')[-1] outputFile = '.'.join([path, cmd, ext]).replace('\\', '/') #adding renderlayer to outputfiles filename = os.path.basename(outputFile) dirpath = os.path.dirname(outputFile) outputFiles.append( os.path.join(dirpath, layer + '_' + filename)) #adding renderlayer to shotgunfiles filename = os.path.basename(shotgunFiles) dirpath = os.path.dirname(shotgunFiles) publishFiles.append( os.path.join(dirpath, layer + '_' + filename)) #getting login for user and replacing with user in shotgunContext shotgunUser = sgtk.util.get_current_user(self.parent.sgtk) #creating the folders for rendering for outputfile in outputFiles: dirpath = os.path.dirname(outputfile) if not os.path.exists(dirpath): os.makedirs(dirpath) #submit to deadline jobname = '.'.join(os.path.basename(mayaFile).split('.')[0:-1]) exportId = cdu.submit('arnoldExport', jobname, start, end, mayaFile, outputPath, [outputFiles[0]], ['ProjectPath=%s' % outputPath], submitArgs, shotgunContext='', shotgunFields='', shotgunUser='', mayaGUI=True) for f in inputFiles: count = inputFiles.index(f) #generate jobname basename = '.'.join(os.path.basename(f).split('.')[0:-2]) layer = f.split('/')[-2] jobname = basename + '.' + layer #execute deadline submittal try: cdu.submit('arnold', jobname, start, end, f, outputPath, [outputFiles[count]], pluginArgs, submitArgs=['JobDependencies=%s' % exportId], shotgunContext=shotgunContext, shotgunFields=shotgunFields, shotgunUser=shotgunUser, mayaGUI=True) except Exception, e: raise TankError("Failed to submit arnold to deadline: %s" % e)
def _arnold_render(self,output): print 'Rendering Arnold!' pluginArgs=[''] submitArgs=['Comment=Shotgun Publish submit'] shotgunContext=self.app.context #getting fields for version shot_temp=self.app.sgtk.templates["maya_shot_work"] shotgunFields=shot_temp.get_fields(output['work_file']) #getting output path area_temp=self.parent.sgtk.templates['maya_shot_render_area'] outputPath=area_temp.apply_fields(shotgunFields).replace('\\','/') #getting ass file path area_temp=self.parent.sgtk.templates['maya_ass_export'] inputFilePath=area_temp.apply_fields(shotgunFields).replace('\\','/') % 1 inputFiles=[] for layer in cmds.ls(type='renderLayer'): #discarding referenced layers if ':' not in layer: #checking whether layer needs to be rendered if cmds.getAttr(layer+'.renderable')==1: if layer=='defaultRenderLayer': layer='masterLayer' #hardcoded replace of output['name'] string--- p=inputFilePath.replace('/data/','/data/%s/' % layer) inputFiles.append(p) #getting output fields render_temp=self.parent.sgtk.templates['maya_shot_render'] outputFiles=render_temp.apply_fields(shotgunFields) outputFields=render_temp.get_fields(outputFiles) #replacing output['name'] with file output['name'] outputFields['name']='.'.join(output['work_file'].split('/')[-1].split('.')[0:-2]) #generate outputFiles shotgunFiles=render_temp.apply_fields(outputFields) outputFiles=[] for layer in cmds.ls(type='renderLayer'): #discarding referenced layers if ':' not in layer: #checking whether layer needs to be rendered if cmds.getAttr(layer+'.renderable')==1: if layer=='defaultRenderLayer': layer='masterLayer' #clunky code to replace seq format with ? cmd='' maxCount=int(shotgunFiles.split('%')[-1].split('.')[0].replace('d','')) for count in xrange(0,maxCount): cmd+='?' path=shotgunFiles.split('%')[0][0:-1] ext=shotgunFiles.split('%')[-1].split('.')[-1] outputFile='.'.join([path,cmd,ext]).replace('\\','/') #adding renderlayer to outputfiles filename=os.path.basename(outputFile) dirpath=os.path.dirname(outputFile) outputFiles.append(os.path.join(dirpath,layer+'_'+filename)) #adding renderlayer to shotgunfiles filename=os.path.basename(shotgunFiles) dirpath=os.path.dirname(shotgunFiles) #getting login for user and replacing with user in shotgunContext shotgunUser=sgtk.util.get_current_user(self.app.sgtk) #creating the folders for rendering for outputfile in outputFiles: dirpath=os.path.dirname(outputfile) if not os.path.exists(dirpath): os.makedirs(dirpath) #submit to deadline exportId=cdu.submit('arnoldExport', output['jobname'], output['start'], output['end'], output['work_file'], outputPath,[outputFiles[0]], ['ProjectPath=%s' % outputPath], submitArgs,shotgunContext='', shotgunFields='',shotgunUser='',mayaGUI=True, limit=output['limit'],priority=output['priority']) for f in inputFiles: count=inputFiles.index(f) #generate jobname layer=f.split('/')[-2] jobname=output['jobname']+'.'+layer #execute deadline submittal cdu.submit('arnold', jobname, output['start'], output['end'], f, outputPath,[outputFiles[count]], pluginArgs, submitArgs=['JobDependencies=%s' % exportId],shotgunContext=shotgunContext, shotgunFields=shotgunFields, shotgunUser=shotgunUser,mayaGUI=True,priority=output['priority'])