def RB_RENDER(self): #5 if self.CheckNetuse(): print("Net use finished!") else: print("Net use not finished yet.") sys.exit(101) self.format_log('渲染', 'start') self.G_DEBUG_LOG.info('[BASE.RB_RENDER.start.....]') self.AnalyzeCallBack() if not self._run_code_result: self.LogsCreat("Errors calls,try to kill apps...") else: self.LogsCreat("Job finished,try to kill apps...") if len(self._Killapps): mainapp = [] self._Killapps.extend(mainapp) try: CLASS_COMMON_UTIL.kill_app_list(self._Killapps) except: pass self.LogsCreat("[kill apps done]") # if errors if not self._run_code_result: CLASS_COMMON_UTIL.error_exit_log(self.G_DEBUG_LOG, "AnalyzeCallBack()", 456) self.G_DEBUG_LOG.info('[BASE.RB_RENDER.end.....]') self.format_log('done', 'end')
def result_action_photon(self): # if self.G_ONLY_PHOTON == '1': # upload_path = self.G_OUTPUT_USER_PATH # else: upload_path = os.path.join(self.G_INPUT_PROJECT_PATH, 'photon', self.G_TASK_ID) # if self.G_KG == '102':#fast inc map # upload_path = os.path.join(self.G_TEMP_PATH,'photon') cmd1 = 'c:\\fcopy\\FastCopy.exe /speed=full /force_close /no_confirm_stop /force_start "' + self.G_WORK_RENDER_TASK_OUTPUT.replace( '/', '\\') + '" /to="' + upload_path + '"' # cmd2='"' +frame_check + '" "' + self.G_WORK_RENDER_TASK_OUTPUT + '" "'+ upload_path.rstrip()+'"' cmd3 = 'c:\\fcopy\\FastCopy.exe /cmd=move /speed=full /force_close /no_confirm_stop /force_start "' + self.G_WORK_RENDER_TASK_OUTPUT.replace( '/', '\\') + '\\*.*" /to="' + self.G_WORK_RENDER_TASK_OUTPUTBAK.replace( '/', '\\') + '"' CLASS_COMMON_UTIL.cmd(cmd1.decode('utf-8').encode( sys.getfilesystemencoding()), my_log=self.G_DEBUG_LOG, try_count=3) # try: # self.check_result() # except Exception, e: # print '[check_result.err]' # print e # CLASS_COMMON_UTIL.cmd(cmd2,my_log=self.G_DEBUG_LOG) CLASS_COMMON_UTIL.cmd(cmd3, my_log=self.G_DEBUG_LOG, try_count=3, continue_on_error=True)
def RB_CONVERT_SMALL_PIC(self): #6 self.format_log('转换缩略图', 'start') self.G_DEBUG_LOG.info('[BASE.RB_CONVERT_SMALL_PIC.start.....]') if self.G_ACTION not in ['Analyze', 'Pre' ] and self.G_RENDER_OS != 'Linux': self.G_DEBUG_LOG.info(self.G_WORK_RENDER_TASK_SMALL) self.G_DEBUG_LOG.info(self.G_SMALL_PATH) if not os.path.exists(self.G_WORK_RENDER_TASK_SMALL): os.makedirs(self.G_WORK_RENDER_TASK_SMALL) exr_to_jpg = os.path.join(self.G_WORK_RENDER_TASK, 'exr2jpg') exr_to_jpg_bak = os.path.join(self.G_WORK_RENDER_TASK, 'exr2jpgbak') self.convert_dir(self.G_WORK_RENDER_TASK_OUTPUT, self.G_WORK_RENDER_TASK_SMALL) self.convert_dir(exr_to_jpg, self.G_WORK_RENDER_TASK_SMALL) move_cmd = 'c:\\fcopy\\FastCopy.exe /cmd=move /speed=full /force_close /no_confirm_stop /force_start "' + self.G_WORK_RENDER_TASK_SMALL.replace( '/', '\\') + '\*.*" /to="' + self.G_SMALL_PATH.replace( '/', '\\') + '"' CLASS_COMMON_UTIL.cmd(move_cmd, my_log=self.G_DEBUG_LOG, continue_on_error=True) if os.path.exists(exr_to_jpg): exr_to_jpg_bak_move = 'c:\\fcopy\\FastCopy.exe /cmd=move /speed=full /force_close /no_confirm_stop /force_start "' + exr_to_jpg.replace( '/', '\\') + '\\*.*" /to="' + exr_to_jpg_bak.replace( '/', '\\') + '"' CLASS_COMMON_UTIL.cmd(exr_to_jpg_bak_move, my_log=self.G_DEBUG_LOG) self.G_DEBUG_LOG.info('[BASE.RB_CONVERT_SMALL_PIC.end.....]') self.format_log('done', 'end')
def result_action_photon(self): if self.G_ONLY_PHOTON == 'true': upload_path = self.G_OUTPUT_USER_PATH self.rename_photon_taskid(self.G_WORK_RENDER_TASK_OUTPUT, self.G_TASK_ID, self.G_SMALL_TASK_ID) else: if self.G_KG == '102':#fast inc map upload_path = os.path.join(self.G_TEMP_PATH,'photon') if self.G_MULTI_CAMERA: upload_path = os.path.join(self.G_TEMP_PATH,'photon',self.G_SMALL_TASK_ID) else: upload_path = os.path.join(self.G_INPUT_PROJECT_PATH,'photon',self.G_SMALL_TASK_ID) self.rename_photon_taskid(self.G_WORK_RENDER_TASK_OUTPUT, self.G_TASK_ID, self.G_SMALL_TASK_ID) cmd1='c:\\fcopy\\FastCopy.exe /speed=full /force_close /no_confirm_stop /force_start "' +self.G_WORK_RENDER_TASK_OUTPUT_XXX.replace('/','\\') +'" /to="'+upload_path+'"' # cmd2='c:\\fcopy\\FastCopy.exe /speed=full /force_close /no_confirm_stop /force_start "' +self.G_WORK_RENDER_TASK_OUTPUT.replace('/','\\') +'" /to="'+self.G_OUTPUT_USER_PATH+'"' # cmd2='"' +frame_check + '" "' + self.G_WORK_RENDER_TASK_OUTPUT + '" "'+ upload_path.rstrip()+'"' cmd3='c:\\fcopy\\FastCopy.exe /cmd=move /speed=full /force_close /no_confirm_stop /force_start "' +self.G_WORK_RENDER_TASK_OUTPUT.replace('/','\\')+'\\*.*" /to="'+self.G_WORK_RENDER_TASK_OUTPUTBAK.replace('/','\\')+'"' self.rendering_copy_notify() CLASS_COMMON_UTIL.cmd(cmd1,my_log=self.G_DEBUG_LOG,try_count=3) # CLASS_COMMON_UTIL.cmd_python3(cmd1,my_log=self.G_DEBUG_LOG) # if upload_path != self.G_OUTPUT_USER_PATH: ##CLASS_COMMON_UTIL.cmd(cmd2.decode('utf-8').encode(sys.getfilesystemencoding()),my_log=self.G_DEBUG_LOG,try_count=3) # CLASS_COMMON_UTIL.cmd_python3(cmd2,my_log=self.G_DEBUG_LOG) # try: # self.check_result() # except Exception, e: # print '[check_result.err]' # print e CLASS_FRAME_CHECKER.main(self.G_WORK_RENDER_TASK_OUTPUT_XXX,upload_path,my_log=self.G_DEBUG_LOG) # CLASS_COMMON_UTIL.cmd(cmd2,my_log=self.G_DEBUG_LOG) CLASS_COMMON_UTIL.cmd(cmd3,my_log=self.G_DEBUG_LOG,try_count=3,continue_on_error=True)
def get_max_vray_log(self): if self.MAX_VRAY_DISTRIBUTE: user_profile=os.environ["userprofile"] user_temp_file=os.environ["temp"] max_log_dir = user_profile+'\\AppData\\Local\\Autodesk\\3dsMax\\'+self.G_CG_VERSION.replace('3ds Max ','')+' - 64bit\\enu\\Network' max_log_dir = max_log_dir.replace('/','\\') max_log_path = os.path.join(max_log_dir,'Max.log').replace('/','\\') vray_log_dir = user_temp_file.replace('/','\\') vray_log_path = os.path.join(vray_log_dir,'vraylog.txt').replace('/','\\') node_ip_list = [] for node_ip in self.G_SCHEDULER_CLUSTER_NODES.split(','): node_ip_list.append(node_ip) self.G_DEBUG_LOG.info(node_ip_list) # nodeIP_num = len(node_ip_list) #numbers of node ip if node_ip_list: for node_ip in node_ip_list: max_log_node_remote = '\\\\' + node_ip + '\\' + max_log_path.replace(':','$') vray_log_node_remote = '\\\\' + node_ip + '\\' + vray_log_path.replace(':','$') max_log_to_master = os.path.join(self.G_LOG_WORK,self.G_TASK_ID,node_ip).replace('/','\\') vray_log_to_master = os.path.join(self.G_LOG_WORK,self.G_TASK_ID,node_ip).replace('/','\\') max_log_cmd=r'c:\fcopy\FastCopy.exe /cmd=force_copy /speed=full /force_close /no_confirm_stop /force_start "'+max_log_node_remote+'" /to="'+max_log_to_master+'"' vray_log_cmd=r'c:\fcopy\FastCopy.exe /cmd=force_copy /speed=full /force_close /no_confirm_stop /force_start "'+vray_log_node_remote+'" /to="'+vray_log_to_master+'"' CLASS_COMMON_UTIL.cmd(max_log_cmd,my_log=self.G_DEBUG_LOG,continue_on_error=True) CLASS_COMMON_UTIL.cmd(vray_log_cmd,my_log=self.G_DEBUG_LOG,continue_on_error=True)
def writeIni(self): self.myLog('--------------------------------[MaxPlugin]writeIni...start--------------------------------\n') includeIniList=self.getIncludeIni() directoryIniList=self.getDirectoryIni() targetPath=os.path.join(self.G_LOCAL_AUTODESK,self.G_CG_VERSION,'en-US','plugin.ini').replace('\\','/') if self.G_CG_VERSION=='3ds Max 2010' or self.G_CG_VERSION=='3ds Max 2011' or self.G_CG_VERSION=='3ds Max 2012': targetPath=os.path.join(self.G_LOCAL_AUTODESK,self.G_CG_VERSION,'plugin.ini').replace('\\','/') if os.path.exists(targetPath): os.system('del /s /q "%s"' % (targetPath)) self.myLog('del ini'+targetPath+'\n') self.myLog('write ini to '+targetPath+'\n') f=open(targetPath,'wb') if includeIniList: f.write(b'[Include]'+b'\n') for includeIni in includeIniList: includeIni = CLASS_COMMON_UTIL.str_to_bytes(includeIni) f.write(includeIni+b'\n') if directoryIniList: f.write(b'[Directory]'+b'\n') for directoryIni in directoryIniList: directoryIni = CLASS_COMMON_UTIL.str_to_bytes(directoryIni) f.write(directoryIni+b'\n') print('write ini finished\n') f.close() print('writeIni...end\n')
def check_texture(self, nuke_path, texture_file, my_log=None): run_path = nuke_path run_path = CLASS_COMMON_UTIL.str_to_unicode(run_path) #print texture_file #print '________',run_path os.environ['HFS'] = run_path _PATH_ORG = os.environ.get('PATH') os.environ['PATH'] = (_PATH_ORG if _PATH_ORG else '') + r';' + run_path #print os.environ['PATH'] lib_path = '%s/lib' % (run_path) # _PATH_New = os.environ.get('PATH') # print '_PATH_New = ' + _PATH_New site_path = '%s/lib/site-packages' % (run_path) if lib_path not in sys.path: sys.path.append(lib_path) if site_path not in sys.path: sys.path.append(site_path) import nuke for i in texture_file: i = i.replace('\\', '/') texture_type = ['avi', 'eps', 'dds', 'bmp', 'vrimg'] if i.split('.')[-1] not in texture_type: #print i readtex = nuke.nodes.Read(file=i.encode('utf-8')) if readtex.metadata() == {}: CLASS_COMMON_UTIL.log_print(my_log, u'File is damaged' + i) else: # print u'ok__________'+i pass else: CLASS_COMMON_UTIL.log_print( my_log, u' This file does not support Nuke do check' + i)
def write_ms_file(self): not_render = 'false' if self.G_CG_VERSION == '3ds Max 2012' or self.G_CG_VERSION == '3ds Max 2011' or self.G_CG_VERSION == '3ds Max 2010' or self.G_CG_VERSION == '3ds Max 2009': render_ms_name = 'rendera2.0.ms' else: render_ms_name = 'renderu2.0.ms' # render_frame = get_render_frame() render_ms = os.path.join(self.G_NODE_MAXSCRIPT, render_ms_name).replace('\\', '/') task_ms_file = os.path.join( self.G_WORK_RENDER_TASK_CFG, ('render' + self.G_CG_FRAMES + '.ms')).replace('\\', '/') # self.MAX_FILE=self.get_max_file(self.G_INPUT_CG_FILE) ms_str = '(DotNetClass "System.Windows.Forms.Application").CurrentCulture = dotnetObject "System.Globalization.CultureInfo" "zh-cn"\r\n' ms_str = ms_str + 'filein @"' + render_ms + '"\r\n' ms_str = ms_str + 'fn renderRun = (\r\n' ms_str = ms_str + 'web_render #("' + self.G_USER_ID + '","' + self.G_TASK_ID + '","' + not_render + '","' + self.G_CG_FRAMES + '","' ms_str = ms_str + self.G_ACTION_ID + '","' + self.G_CG_OPTION + '","' + self.G_ACTION + '","' + self.G_WORK_RENDER_TASK_OUTPUT.replace( '\\', '/') + '/' + '","' + self.MAX_FILE + '", @"' ms_str = ms_str + self.G_TASK_JSON.replace('\\', '/') + '"' ms_str = ms_str + ',"' + self.G_KG + '"' ms_str = ms_str + ') \r\n)' if self.G_CG_VERSION == '3ds Max 2012' or self.G_CG_VERSION == '3ds Max 2011' or self.G_CG_VERSION == '3ds Max 2010' or self.G_CG_VERSION == '3ds Max 2009': CLASS_COMMON_UTIL.write_file(ms_str, task_ms_file, my_code='utf-8') else: CLASS_COMMON_UTIL.write_file(ms_str, task_ms_file, my_code='gbk') self.G_DEBUG_LOG.info('[RenderMax.write_ms_file.end.....]') return task_ms_file
def RB_CONFIG(self): #4 if self.CheckNetuse(): print("Net use finished!") else: print("Net use not finish yet.") sys.exit() self.format_log('渲染配置', 'start') self.G_DEBUG_LOG.info('[BASE.RB_CONFIG.start.....]') ## setup Houdini software and plugins for analysis self.Execute_Hfs() if not self._run_code_result: self.LogsCreat("Errors calls,try to kill apps...") print(self._Killapps) if len(self._Killapps): mainapp = [] self._Killapps.extend(mainapp) try: CLASS_COMMON_UTIL.kill_app_list(self._Killapps) except: pass self.G_DEBUG_LOG.info('[BASE.RB_RENDER.end.....]') CLASS_COMMON_UTIL.error_exit_log(self.G_DEBUG_LOG, "Execute_Hfs()", 123) self.G_DEBUG_LOG.info('[BASE.RB_CONFIG.end.....]') self.format_log('done', 'end')
def RB_HAN_RESULT(self): #7 self.format_log('.结果处理...', 'start') self.G_DEBUG_LOG.info('[BASE.RB_HAN_RESULT.start.....]') if self.G_ACTION in ['Analyze']: task_json_name = 'task.json' asset_json_name = 'asset.json' tips_json_name = 'tips.json' node_task_json = os.path.join(self.G_WORK_RENDER_TASK_CFG, task_json_name) node_asset_json = os.path.join(self.G_WORK_RENDER_TASK_CFG, asset_json_name) node_tips_json = os.path.join(self.G_WORK_RENDER_TASK_CFG, tips_json_name) if not os.path.exists(node_task_json): CLASS_COMMON_UTIL.error_exit_log( self.G_DEBUG_LOG, 'Analyze file failed . task.json not exists') self.copy_cfg_to_server(node_task_json, node_asset_json, node_tips_json) else: self.result_action() self.G_DEBUG_LOG.info('[BASE.RB_HAN_RESULT.end.....]') self.format_log('done', 'end')
def subst_path(self): self.G_DEBUG_LOG.info('[RenderMax.subst_path.start.....]') bat_str = '' for file_name in os.listdir(self.G_WORK_RENDER_TASK_MAX): self.G_DEBUG_LOG.info(file_name) if os.path.isfile( os.path.join(self.G_WORK_RENDER_TASK_MAX, file_name)): continue dir_name = file_name.lower() dir_path = os.path.join(self.G_WORK_RENDER_TASK_MAX, file_name).lower() self.G_DEBUG_LOG.info(dir_name) if dir_name == 'net': continue if dir_name == 'default': continue if dir_name == 'b' or dir_name == 'c' or dir_name == 'd': continue #e,f,g... if len(dir_name) == 1: subst_cmd = 'subst ' + dir_name + ': "' + dir_path + '"' self.G_DEBUG_LOG.info(subst_cmd) os.system(subst_cmd) bat_str = bat_str + subst_cmd + '\r\n' bat_file = os.path.join(self.G_WORK_RENDER_TASK_CFG, 'substDriver.bat') CLASS_COMMON_UTIL.write_file(bat_str, bat_file) self.G_DEBUG_LOG.info('[RenderMax.subst_path.end.....]')
def __init__(self,**param_dict): RenderBase.__init__(self,**param_dict) #global variable if self.G_ACTION != 'Analyze': self.G_KG='0' if (self.G_TASK_JSON_DICT['scene_info_render']['renderer'].has_key('gi') and self.G_TASK_JSON_DICT['scene_info_render']['renderer']['gi'] == '1') and (self.G_TASK_JSON_DICT['scene_info_render']['renderer'].has_key('primary_gi_engine') and self.G_TASK_JSON_DICT['scene_info_render']['renderer']['primary_gi_engine'] == '0'): if self.G_TASK_JSON_DICT['scene_info_render']['renderer'].has_key('irradiance_map_mode') and self.G_TASK_JSON_DICT['scene_info_render']['renderer']['irradiance_map_mode'] == '4': self.G_KG='100' if self.G_TASK_JSON_DICT['scene_info_render']['renderer'].has_key('photonNode') and self.G_TASK_JSON_DICT['scene_info_render']['renderer']['photonNode'] == '1': self.G_KG='102' if self.G_TASK_JSON_DICT['scene_info_render']['renderer'].has_key('irradiance_map_mode') and self.G_TASK_JSON_DICT['scene_info_render']['renderer']['irradiance_map_mode'] == '6': self.G_KG='101' self.G_WORK_RENDER_TASK_BLOCK=os.path.normpath(os.path.join(self.G_WORK_RENDER_TASK,'block')) self.G_WORK_RENDER_TASK_GRAB=os.path.normpath(os.path.join(self.G_WORK_RENDER_TASK,'grab')) self.G_WORK_RENDER_TASK_MAX=os.path.normpath(os.path.join(self.G_WORK_RENDER_TASK,'max')) self.G_WORK_RENDER_TASK_MAXBAK=os.path.normpath(os.path.join(self.G_WORK_RENDER_TASK,'maxbak')) self.G_CG_VERSION=self.G_TASK_JSON_DICT['software_config']['cg_name']+' '+self.G_TASK_JSON_DICT['software_config']['cg_version'] dir_list=[] dir_list.append(self.G_WORK_RENDER_TASK_BLOCK) dir_list.append(self.G_WORK_RENDER_TASK_GRAB) dir_list.append(self.G_WORK_RENDER_TASK_MAX) dir_list.append(self.G_WORK_RENDER_TASK_MAXBAK) CLASS_COMMON_UTIL.make_dirs(dir_list) self.G_MAX_B=os.path.normpath('B:/plugins/max') self.G_MAX_SCRIPT=os.path.join(self.G_MAX_B,'script') self.G_NODE_MAXSCRIPT=os.path.normpath(os.path.join(self.G_NODE_PY,'CG/Max/maxscript')) # self.G_NODE_PY_CUSTOM=os.path.normpath(os.path.join(self.G_NODE_PY,'custom')) self.ASSET_WEB_COOLECT_BY_PATH=False if self.G_TASK_JSON_DICT.has_key('miscellaneous') and self.G_TASK_JSON_DICT['miscellaneous'].has_key('only_photon'): self.G_ONLY_PHOTON = self.G_TASK_JSON_DICT['miscellaneous']['only_photon']
def handle_file(self, frame): """result_action 的复制版, 去掉了帧检查""" self.G_DEBUG_LOG.info('[Maya.result_action.start.....]') output = self.G_OUTPUT_USER_PATH if not os.path.exists(output): os.makedirs(output) frame = frame.zfill(4) if self.G_CG_TILE_COUNT != '1' and self.G_CG_TILE_COUNT != self.G_CG_TILE: output = self.G_TILES_PATH cmd1 = '{fcopy_path} /speed=full /force_close /no_confirm_stop /force_start "{source}" /to="{destination}"'.format( fcopy_path='c:\\fcopy\\FastCopy.exe', source=os.path.join( self.G_WORK_RENDER_TASK_OUTPUT.replace('/', '\\'), frame), destination=output.replace('/', '\\'), ) cmd3 = '{fcopy_path} /speed=full /cmd=move /force_close /no_confirm_stop /force_start "{source}" /to="{destination}"'.format( fcopy_path='c:\\fcopy\\FastCopy.exe', source=os.path.join( self.G_WORK_RENDER_TASK_OUTPUT.replace('/', '\\'), frame), destination=self.G_WORK_RENDER_TASK_OUTPUTBAK.replace('/', '\\'), ) CLASS_COMMON_UTIL.cmd(cmd1, my_log=self.G_DEBUG_LOG, try_count=3, continue_on_error=True) CLASS_COMMON_UTIL.cmd(cmd3, my_log=self.G_DEBUG_LOG, try_count=3, continue_on_error=True) self.G_DEBUG_LOG.info('[Max.result_action.end.....]')
def RB_RENDER(self): self.format_log('合并光子开始', 'start') self.G_DEBUG_LOG.info('[Merge.RB_RENDER start]') self.G_FEE_PARSER.set('render', 'start_time', str(int(time.time()))) # 调用合并光子方法 photon_path = os.path.join(self.G_WORK_RENDER_TASK, 'photon', 'source') photon_user_path = os.path.join(self.G_TEMP_PATH, 'photon') if self.G_MULTI_CAMERA: photon_user_path = os.path.join(self.G_TEMP_PATH, 'photon', self.G_SMALL_TASK_ID) if not os.path.exists(photon_path): os.makedirs(photon_path) self.G_DEBUG_LOG.info(photon_path) self.G_DEBUG_LOG.info(photon_user_path) if os.path.exists(photon_user_path): copy_vrmap_cmd = r'c:\fcopy\FastCopy.exe /speed=full /force_close /no_confirm_stop /force_start "' + photon_user_path + '\\*.vr*map" /to="' + photon_path + '"' CLASS_COMMON_UTIL.cmd(copy_vrmap_cmd, my_log=self.G_DEBUG_LOG) self.G_DEBUG_LOG.info('photon_path =' + str(photon_path)) self.show_path_file(photon_path) #-----------------------------------------merge photon----------------------------------------------- self.merge_photon(photon_path) self.G_FEE_PARSER.set('render', 'end_time', str(int(time.time()))) self.G_DEBUG_LOG.info('[Merge.RB_RENDER end]') self.format_log('合并光子结束', 'end')
def do(self): max_log_list = [] vray_log_list = [] if os.path.exists(self.MAX_LOG): self.RENDER_LOG.info('[MonitorLog].handle maxlog...') # max_log_list=self.readFile(self.MAX_LOG) max_log_list = CLASS_COMMON_UTIL.read_random_file(self.MAX_LOG) # self.writeFile(self.WORK_MAX_LOG,max_log_list,'w') self.writeFile(self.WORK_NEW_RENDER_LOG, [ "\n\n======================================================================maxlog======================================================================\n\n" ], 'w') self.writeFile(self.WORK_NEW_RENDER_LOG, max_log_list, 'a+') if os.path.exists(self.VRAY_LOG): self.RENDER_LOG.info('[MonitorLog].handle vraylog...') # vray_log_list=self.readFile(self.VRAY_LOG) vray_log_list = CLASS_COMMON_UTIL.read_random_file(self.VRAY_LOG) # self.writeFile(self.WORK_VRAY_LOG,vray_log_list,'w') self.writeFile(self.WORK_NEW_RENDER_LOG, [ "\n\n======================================================================vraylog======================================================================\n\n" ], 'a+') self.writeFile(self.WORK_NEW_RENDER_LOG, vray_log_list, 'a+') self.RENDER_LOG.info('[MonitorLog].sleep...') return max_log_list, vray_log_list
def RB_RENDER(self): #5 self.format_log('渲染', 'start') self.G_DEBUG_LOG.info('[BASE.RB_RENDER.start.....]') self.RenderCallBack() if not self._run_code_result: self.LogsCreat("Errors calls,try to kill apps...") else: self.LogsCreat("Job finished,try to kill apps...") if len(self._Killapps): mainapp = ["hython.exe"] self._Killapps.extend(mainapp) try: CLASS_COMMON_UTIL.kill_app_list(self._Killapps) except: pass self.LogsCreat("[kill apps done]") # if errors if not self._run_code_result: CLASS_COMMON_UTIL.error_exit_log(self.G_DEBUG_LOG, "RenderCallBack()", 456) self.G_DEBUG_LOG.info('[BASE.RB_RENDER.end.....]') self.format_log('done', 'end')
def __init__(self,**param_dict): RenderBase.__init__(self,**param_dict) #global variable if self.G_ACTION != 'Analyze': renderer = self.G_TASK_JSON_DICT['scene_info_render']['renderer'] ## kg self.G_KG='0' if renderer.get('gi', None) == '1': # 0:gi off / 1:gi on if renderer.get('primary_gi_engine', None) == '0' and renderer.get('irradiance_map_mode', None) == '6': # Animation(prepass) self.G_KG='101' elif (renderer.get('primary_gi_engine', None) == '0' and renderer.get('irradiance_map_mode', None) == '4') or ( (renderer.get('primary_gi_engine', None) == '3' or renderer.get('secondary_gi_engine', None) == '3') and renderer.get('light_cache_mode', None) == '1'): # Incremental add to current map/Fly-through self.G_KG='100' if renderer.get('photonnode', None) == '1': # 0:single node / 1:multi node self.G_KG='102' ## onlyphoton self.G_ONLY_PHOTON = renderer.get('onlyphoton', None) ## multi camera self.G_MULTI_CAMERA = False self.G_WORK_RENDER_TASK_OUTPUT_XXX = self.G_WORK_RENDER_TASK_OUTPUT.replace('\\','/') if 'renderable_camera' in self.G_TASK_JSON_DICT['scene_info_render']['common']: renderable_camera = self.G_TASK_JSON_DICT['scene_info_render']['common']['renderable_camera'] #list if len(renderable_camera) > 1: self.G_MULTI_CAMERA = True self.G_WORK_RENDER_TASK_OUTPUT_XXX = self.G_WORK_RENDER_TASK_OUTPUT_XXX + '/' + self.G_SMALL_TASK_ID ## task.json(ascii) self.G_TASK_JSON_A = os.path.normpath(os.path.join(self.G_WORK_RENDER_TASK_CFG,'task_a.json')) if self.G_CG_VERSION=='3ds Max 2012' or self.G_CG_VERSION=='3ds Max 2011' or self.G_CG_VERSION=='3ds Max 2010' or self.G_CG_VERSION=='3ds Max 2009': with codecs.open(self.G_TASK_JSON,'rb','utf-8') as fp1: with codecs.open(self.G_TASK_JSON_A,'wb',sys.getfilesystemencoding()) as fp2: content = fp1.read() fp2.write(content) self.G_WORK_RENDER_TASK_BLOCK=os.path.normpath(os.path.join(self.G_WORK_RENDER_TASK,'block')) self.G_WORK_RENDER_TASK_GRAB=os.path.normpath(os.path.join(self.G_WORK_RENDER_TASK,'grab')) self.G_WORK_RENDER_TASK_MAX=os.path.normpath(os.path.join(self.G_WORK_RENDER_TASK,'max')) self.G_WORK_RENDER_TASK_MAXBAK=os.path.normpath(os.path.join(self.G_WORK_RENDER_TASK,'maxbak')) self.G_CG_VERSION=self.G_TASK_JSON_DICT['software_config']['cg_name']+' '+self.G_TASK_JSON_DICT['software_config']['cg_version'] dir_list=[] dir_list.append(self.G_WORK_RENDER_TASK_BLOCK) dir_list.append(self.G_WORK_RENDER_TASK_GRAB) dir_list.append(self.G_WORK_RENDER_TASK_MAX) dir_list.append(self.G_WORK_RENDER_TASK_MAXBAK) CLASS_COMMON_UTIL.make_dirs(dir_list) self.G_MAX_B=os.path.normpath('B:/plugins/max') self.G_MAX_SCRIPT=os.path.join(self.G_MAX_B,'script') self.G_NODE_MAXSCRIPT=os.path.normpath(os.path.join(self.G_NODE_PY,'CG/Max/script')) # self.G_NODE_PY_CUSTOM=os.path.normpath(os.path.join(self.G_NODE_PY,'custom')) self.ASSET_WEB_COOLECT_BY_PATH=False
def copy_black(self): self.G_DEBUG_LOG.info('[BASE.copy_black.start.....]') block_path = 'B:\\tools\\sweeper\\black.xml' base_path = 'c:\\work\\munu_client\\sweeper\\' self.G_DEBUG_LOG.info(block_path + '>' + base_path) if os.path.exists(block_path): CLASS_COMMON_UTIL.python_copy(block_path, base_path) self.G_DEBUG_LOG.info('[BASE.copy_black.end.....]')
def RB_HAN_FILE(self):#3 copy max.7z and so on self.format_log('拷贝脚本文件','start') self.G_DEBUG_LOG.info('[BASE.RB_HAN_FILE.start.....]'+self.G_RENDER_CORE_TYPE) CLASS_COMMON_UTIL.python_move(self.G_WORK_RENDER_TASK_OUTPUT,self.G_WORK_RENDER_TASK_OUTPUTBAK) self.G_DEBUG_LOG.info('[BASE.RB_HAN_FILE.end.....]') self.format_log('done','end')
def convert_dir(self,dir,work_small_path): self.G_DEBUG_LOG.info('[BASE.convert_dir.start.....]') if os.path.exists(dir): small_size='200' # if self.G_KG=='1': # small_size='40' small_pic_list=[] # big_pic_list=[] list_dirs = os.walk(dir) for root, dirs, files in list_dirs: for name in files: ext=os.path.splitext(name)[1] self.G_DEBUG_LOG.info('name='+name) if ext == '.vrmap' or ext == '.vrlmap' or ext=='.exr': continue work_big_pic =os.path.join(root, name) # big_pic_list.append(work_big_pic.replace(dir+'\\','').replace('\\','/')) small_pic=work_big_pic.replace(dir+'\\','') small_pic=self.G_ACTION_ID+"_"+small_pic.replace('\\','[_]').replace('/','[_]').replace('.','[-]')+'.jpg' small_pic_list.append(small_pic.replace('\\','/')) small_tmp_name = self.G_ACTION_ID+'_tmp.jpg' work_small_pic=os.path.join(work_small_path,small_pic) work_small_tmp_pic=os.path.join(work_small_path,small_tmp_name) work_big_pic_tmp=os.path.join(root, 'tmp'+os.path.splitext(work_big_pic)[1] ) try: os.rename(work_big_pic,work_big_pic_tmp); except Exception as e: self.G_DEBUG_LOG.info('rename failed-----') pass if not os.path.exists(work_big_pic_tmp): work_big_pic_tmp = work_big_pic work_small_tmp_pic = work_small_pic oiio_path='c:\\oiio\\OpenImageIO-1.5.18-bin-vc9-x64\\oiiotool.exe' convert_cmd='c:/ImageMagick/nconvert.exe -out jpeg -ratio -resize '+small_size+' 0 -overwrite -o "'+work_small_tmp_pic +'" "'+work_big_pic_tmp+'"' if ext=='.exr' and os.path.exists(oiio_path): self.G_DEBUG_LOG.info('exr parse----'+name) convert_cmd=oiio_path+' "'+work_big_pic_tmp+'" -resize '+self.get_convert_r(work_big_pic_tmp,oiio_path)+' -o "'+work_small_tmp_pic+'"' #print work_big_pic try: # CLASS_COMMON_UTIL.cmd(convert_cmd,my_log=self.G_DEBUG_LOG,continue_on_error=True) # CLASS_COMMON_UTIL.cmd_python3(convert_cmd,my_log=self.G_DEBUG_LOG) CLASS_COMMON_UTIL.cmd(convert_cmd,my_log=self.G_DEBUG_LOG) except Exception as e: self.G_DEBUG_LOG.info('parse smallPic failed-----') pass if not work_big_pic_tmp==work_big_pic: os.rename(work_big_pic_tmp,work_big_pic) if os.path.exists(work_small_tmp_pic): os.rename(work_small_tmp_pic,work_small_pic) self.G_DEBUG_LOG.info('work_small_tmp_pic---'+work_small_tmp_pic+'---work_small_pic---'+work_small_pic+'---work_big_pic_tmp---'+work_big_pic_tmp+'---work_big_pic---'+work_big_pic) # self.G_KAFKA_MESSAGE_DICT['small_pic']=small_pic_list # self.G_KAFKA_MESSAGE_DICT['big_pic']=big_pic_list small_pic_str = '|'.join(small_pic_list) self.G_FEE_PARSER.set('render','small_pic',small_pic_str) self.G_DEBUG_LOG.info('[BASE.convert_dir.end.....]')
def __init__(self,**paramDict): print("Houdini class") RenderBase.__init__(self,**paramDict) self.format_log('Houdini.init','start') self.G_RENDER_OPTIONS = {"render_rop":self.G_CG_OPTION} if self.G_CG_OPTION !=''else {} dir_list=[] CLASS_COMMON_UTIL.make_dirs(dir_list) self.format_log('done','end')
def __init__(self, **paramDict): print("Keyshot class") RenderBase.__init__(self, **paramDict) self.format_log('Keyshot.init', 'start') dir_list = [] CLASS_COMMON_UTIL.make_dirs(dir_list) self.Updata() self.format_log('done', 'end')
def c4d_cmd_callback(self, my_popen, my_log): while my_popen.poll() == None: render_info = my_popen.stdout.readline().strip() if render_info == "": # self.G_DEBUG_LOG.info(render_info) # r_err = render_info continue CLASS_COMMON_UTIL.log_print(my_log, render_info)
def result_action(self): self.G_DEBUG_LOG.info('[BASE.result_action.start.....]') #RB_small if not os.path.exists(self.G_SMALL_PATH): os.makedirs(self.G_SMALL_PATH) if self.G_RENDER_OS == '0': output_path = "/output" outputbak_path = "/outputbak" sp_path = 'outputdata5' output_folder = self.G_OUTPUT_USER_PATH[ self.G_OUTPUT_USER_PATH.rfind(sp_path) + len(sp_path):len(self.G_OUTPUT_USER_PATH)] output_mnt_path = self.G_OUTPUT_USER_PATH.replace( output_folder, '').replace('\\', '/') output_mnt = 'mount -t cifs -o username=administrator,password=Rayvision@2016,codepage=936,iocharset=gb2312 ' + output_mnt_path + ' ' + output_path if not os.path.exists(output_path): os.makedirs(output_path) CLASS_COMMON_UTIL.cmd(output_mnt, my_shell=True) output_path = output_path + output_folder.replace("\\", "/") if not os.path.exists(output_path): os.makedirs(output_path) CLASS_COMMON_UTIL.python_copy(self.G_WORK_RENDER_TASK_OUTPUT, output_path) CLASS_COMMON_UTIL.python_copy(self.G_WORK_RENDER_TASK_OUTPUT, self.G_WORK_RENDER_TASK_OUTPUTBAK) else: # output=self.G_OUTPUT_USER_PATH.encode(sys.getfilesystemencoding()) output = self.G_OUTPUT_USER_PATH if self.G_CG_TILE_COUNT != '1' and self.G_CG_TILE_COUNT != self.G_CG_TILE: output = self.G_TILES_PATH cmd1 = 'c:\\fcopy\\FastCopy.exe /speed=full /force_close /no_confirm_stop /force_start "' + self.G_WORK_RENDER_TASK_OUTPUT.replace( '/', '\\') + '" /to="' + output + '"' # cmd2='"' +frame_check + '" "' + self.G_WORK_RENDER_TASK_OUTPUT + '" "'+ output.rstrip()+'"' cmd3 = 'c:\\fcopy\\FastCopy.exe /cmd=move /speed=full /force_close /no_confirm_stop /force_start "' + self.G_WORK_RENDER_TASK_OUTPUT.replace( '/', '\\' ) + '\\*.*" /to="' + self.G_WORK_RENDER_TASK_OUTPUTBAK.replace( '/', '\\') + '"' CLASS_COMMON_UTIL.cmd(cmd1, my_log=self.G_DEBUG_LOG, try_count=3) # CLASS_COMMON_UTIL.cmd_python3(cmd1,my_log=self.G_DEBUG_LOG) try: self.check_result() except Exception as e: print('[check_result.err]') print(e) CLASS_FRAME_CHECKER.main(self.G_WORK_RENDER_TASK_OUTPUT, output, my_log=self.G_DEBUG_LOG) # CLASS_COMMON_UTIL.cmd(cmd2,my_log=self.G_DEBUG_LOG) CLASS_COMMON_UTIL.cmd(cmd3, my_log=self.G_DEBUG_LOG, try_count=3, continue_on_error=True) self.G_DEBUG_LOG.info('[BASE.result_action.end.....]')
def main(self, local_path, server_path, my_log=None): nuke_path = r'C:/Program Files/Nuke10.0v4' check_file = self.get_file_size(local_path, server_path, my_log) if not check_file: CLASS_COMMON_UTIL.error_exit_log(my_log, 'output have no file!') if platform.system() == 'Linux': pass else: if os.path.exists(nuke_path): self.check_texture(nuke_path, check_file, my_log)
def copy_photon(self): if self.G_KG=='100' or self.G_KG=='101' or self.G_KG=='102':#inc if self.G_ACTION == 'Render': photon_project_path=os.path.join(self.G_INPUT_PROJECT_PATH,'photon',self.G_TASK_ID) photon_project_path = photon_project_path.decode('utf-8') photon_work_path=os.path.join(self.G_WORK_RENDER_TASK_MAX,'photon') if os.path.exists(photon_project_path): copy_photon_cmd=ur'c:\fcopy\FastCopy.exe /speed=full /force_close /no_confirm_stop /force_start "'+photon_project_path.replace('/','\\')+'\\*.*" /to="'+photon_work_path.replace('/','\\')+'"' ##CLASS_COMMON_UTIL.cmd(copy_photon_cmd.encode(sys.getfilesystemencoding()),my_log=self.G_DEBUG_LOG) CLASS_COMMON_UTIL.cmd_python3(copy_photon_cmd,my_log=self.G_DEBUG_LOG)
def RB_CONVERT_SMALL_PIC(self): #6 if self.G_ACTION not in ['Analyze', 'Pre']: self.format_log('转换缩略图', 'start') self.G_DEBUG_LOG.info('[BASE.RB_CONVERT_SMALL_PIC.start.....]') #kafka--big_pic big_pic_list = [] list_dirs = os.walk(self.G_WORK_RENDER_TASK_OUTPUT) for root, dirs, files in list_dirs: for name in files: work_big_pic = os.path.join(root, name) big_pic_list.append( work_big_pic.replace( self.G_WORK_RENDER_TASK_OUTPUT + os.sep, '').replace( '\\', '/')) #kafka message must use '/' , No '\' # self.G_KAFKA_MESSAGE_DICT['big_pic']=big_pic_list big_pic_str = '|'.join(big_pic_list) if self.G_ACTION in ['RenderPhoton', 'MergePhoton']: self.G_FEE_PARSER.set('render', 'big_pic', '') else: self.G_FEE_PARSER.set('render', 'big_pic', big_pic_str) #convert small pic #kafka--small_pic if self.G_RENDER_OS != '0': self.G_DEBUG_LOG.info(self.G_WORK_RENDER_TASK_SMALL) self.G_DEBUG_LOG.info(self.G_SMALL_PATH) if not os.path.exists(self.G_WORK_RENDER_TASK_SMALL): os.makedirs(self.G_WORK_RENDER_TASK_SMALL) exr_to_jpg = os.path.join(self.G_WORK_RENDER_TASK, 'exr2jpg') exr_to_jpg_bak = os.path.join(self.G_WORK_RENDER_TASK, 'exr2jpgbak') self.convert_dir(self.G_WORK_RENDER_TASK_OUTPUT, self.G_WORK_RENDER_TASK_SMALL) self.convert_dir(exr_to_jpg, self.G_WORK_RENDER_TASK_SMALL) move_cmd = 'c:\\fcopy\\FastCopy.exe /cmd=move /speed=full /force_close /no_confirm_stop /force_start "' + self.G_WORK_RENDER_TASK_SMALL.replace( '/', '\\') + '\*.*" /to="' + self.G_SMALL_PATH.replace( '/', '\\') + '"' CLASS_COMMON_UTIL.cmd(move_cmd, my_log=self.G_DEBUG_LOG, continue_on_error=True) if os.path.exists(exr_to_jpg): exr_to_jpg_bak_move = 'c:\\fcopy\\FastCopy.exe /cmd=move /speed=full /force_close /no_confirm_stop /force_start "' + exr_to_jpg.replace( '/', '\\') + '\\*.*" /to="' + exr_to_jpg_bak.replace( '/', '\\') + '"' CLASS_COMMON_UTIL.cmd(exr_to_jpg_bak_move, my_log=self.G_DEBUG_LOG) self.G_DEBUG_LOG.info('[BASE.RB_CONVERT_SMALL_PIC.end.....]') self.format_log('done', 'end')
def __init__(self,**param_dict): RenderBase.__init__(self,**param_dict) #global variable if self.G_ACTION != 'Analyze': ## kg self.G_KG='0' if (self.G_TASK_JSON_DICT['scene_info_render']['renderer'].has_key('gi') and self.G_TASK_JSON_DICT['scene_info_render']['renderer']['gi'] == '1') and (self.G_TASK_JSON_DICT['scene_info_render']['renderer'].has_key('primary_gi_engine') and self.G_TASK_JSON_DICT['scene_info_render']['renderer']['primary_gi_engine'] == '0'): if self.G_TASK_JSON_DICT['scene_info_render']['renderer'].has_key('irradiance_map_mode') and self.G_TASK_JSON_DICT['scene_info_render']['renderer']['irradiance_map_mode'] == '4': self.G_KG='100' if self.G_TASK_JSON_DICT['scene_info_render']['renderer'].has_key('photonnode') and self.G_TASK_JSON_DICT['scene_info_render']['renderer']['photonnode'] == '1': self.G_KG='102' if self.G_TASK_JSON_DICT['scene_info_render']['renderer'].has_key('irradiance_map_mode') and self.G_TASK_JSON_DICT['scene_info_render']['renderer']['irradiance_map_mode'] == '6': self.G_KG='101' ## multi camera self.G_MULTI_CAMERA = False self.G_WORK_RENDER_TASK_OUTPUT_XXX = self.G_WORK_RENDER_TASK_OUTPUT.replace('\\','/') if self.G_TASK_JSON_DICT['scene_info_render']['common'].has_key('renderable_camera'): renderable_camera = self.G_TASK_JSON_DICT['scene_info_render']['common']['renderable_camera'] #list if len(renderable_camera) > 1: self.G_MULTI_CAMERA = True self.G_WORK_RENDER_TASK_OUTPUT_XXX = self.G_WORK_RENDER_TASK_OUTPUT_XXX + '/' + self.G_CG_OPTION ## task.json(ascii) self.G_TASK_JSON_A = os.path.normpath(os.path.join(self.G_WORK_RENDER_TASK_CFG,'task_a.json')) if self.G_CG_VERSION=='3ds Max 2012' or self.G_CG_VERSION=='3ds Max 2011' or self.G_CG_VERSION=='3ds Max 2010' or self.G_CG_VERSION=='3ds Max 2009': with codecs.open(self.G_TASK_JSON,'rb','utf-8') as fp1: with codecs.open(self.G_TASK_JSON_A,'wb',sys.getfilesystemencoding()) as fp2: content = fp1.read() fp2.write(content) self.G_WORK_RENDER_TASK_BLOCK=os.path.normpath(os.path.join(self.G_WORK_RENDER_TASK,'block')) self.G_WORK_RENDER_TASK_GRAB=os.path.normpath(os.path.join(self.G_WORK_RENDER_TASK,'grab')) self.G_WORK_RENDER_TASK_MAX=os.path.normpath(os.path.join(self.G_WORK_RENDER_TASK,'max')) self.G_WORK_RENDER_TASK_MAXBAK=os.path.normpath(os.path.join(self.G_WORK_RENDER_TASK,'maxbak')) self.G_CG_VERSION=self.G_TASK_JSON_DICT['software_config']['cg_name']+' '+self.G_TASK_JSON_DICT['software_config']['cg_version'] dir_list=[] dir_list.append(self.G_WORK_RENDER_TASK_BLOCK) dir_list.append(self.G_WORK_RENDER_TASK_GRAB) dir_list.append(self.G_WORK_RENDER_TASK_MAX) dir_list.append(self.G_WORK_RENDER_TASK_MAXBAK) CLASS_COMMON_UTIL.make_dirs(dir_list) self.G_MAX_B=os.path.normpath('B:/plugins/max') self.G_MAX_SCRIPT=os.path.join(self.G_MAX_B,'script') self.G_NODE_MAXSCRIPT=os.path.normpath(os.path.join(self.G_NODE_PY,'CG/Max/maxscript')) # self.G_NODE_PY_CUSTOM=os.path.normpath(os.path.join(self.G_NODE_PY,'custom')) self.ASSET_WEB_COOLECT_BY_PATH=False if self.G_TASK_JSON_DICT.has_key('miscellaneous') and self.G_TASK_JSON_DICT['miscellaneous'].has_key('only_photon'): self.G_ONLY_PHOTON = self.G_TASK_JSON_DICT['miscellaneous']['only_photon']
def copy_black(self): self.G_DEBUG_LOG.info('[BASE.copy_black.start.....]') block_path = 'B:\\tools\\sweeper\\black.xml' base_path='c:\\work\\munu_client\\sweeper\\' if self.G_RENDER_OS=='Linux': block_path="\\B\\tools\\sweeper\\black.xml" base_path="/root/rayvision/work/munu_client/sweeper/" self.G_DEBUG_LOG.info(block_path+'>'+base_path) if os.path.exists(block_path): CLASS_COMMON_UTIL.python_copy(block_path,base_path) self.G_DEBUG_LOG.info('[BASE.copy_black.end.....]')
def max_cmd_callback(self,my_popen,my_log): while my_popen.poll()==None: result_line = my_popen.stdout.readline().strip() if result_line=='' : continue CLASS_COMMON_UTIL.log_print(my_log,result_line) if '[_____KILL MAX_____]' in result_line: self.kill_max(my_popen.pid,my_log) CLASS_COMMON_UTIL.log_print(my_log,'\n\n-------------------------------------------End max program-------------------------------------------\n\n')