def RB_MAP_DRIVE(self): #2 self.format_log('映射盘符', 'start') self.G_DEBUG_LOG.info('[BASE.RB_MAP_DRIVE.start.....]') #delete all mappings CLASS_COMMON_UTIL.del_net_use() CLASS_COMMON_UTIL.del_subst() #net use b_flag = False if self.G_CG_NAME != 'Max' and self.G_TASK_JSON_DICT[ 'system_info'].has_key('mnt_map'): map_dict = self.G_TASK_JSON_DICT['system_info']['mnt_map'] for key, value in map_dict.items(): value = os.path.normpath(value) map_cmd = 'net use "%s" "%s"' % (key, value) CLASS_COMMON_UTIL.cmd_python3(map_cmd, my_log=self.G_DEBUG_LOG) if key.lower() == 'b:': b_flag = True if not b_flag: map_cmd_b = 'net use B: "%s"' % (os.path.normpath( self.G_PLUGIN_PATH)) CLASS_COMMON_UTIL.cmd(map_cmd_b, my_log=self.G_DEBUG_LOG, try_count=3) self.G_DEBUG_LOG.info('[BASE.RB_MAP_DRIVE.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_SMALL_TASK_ID) if self.G_MULTI_CAMERA: upload_path = os.path.join(self.G_INPUT_PROJECT_PATH, 'photon', self.G_SMALL_TASK_ID, self.G_CG_OPTION) # 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) CLASS_COMMON_UTIL.cmd_python3(cmd1, my_log=self.G_DEBUG_LOG) # 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 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 == 'Linux': 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()) 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, 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)
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 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, 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) except Exception, 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)
def RB_RENDER(self): self.format_log('拷贝小光子开始', 'start') # outputFiles=False # if self.G_TASK_JSON_DICT['miscellaneous'].has_key('only_photon'): # if self.G_TASK_JSON_DICT['miscellaneous']['only_photon'] == '1': # pass # self.G_OSS_OUTPUT_DIR=self.RvOssOutputRoot()+'d/output/'+self.RvUnionUserIdAndTaskId() # self.G_FEE_LOG.info('startTime='+str(int(time.time()))) # self.G_FEE_LOG.info('endTime='+str(int(time.time()))) # self.G_DEBUG_LOG.info('startTime='+str(int(time.time()))) # self.G_DEBUG_LOG.info('endTime='+str(int(time.time()))) # self.G_KAFKA_MESSAGE_DICT['start_time']=str(int(time.time())) self.G_FEE_PARSER.set('render', 'start_time', str(int(time.time()))) # 调用合并光子方法 #photon_path='A:/photon/'+self.G_TASK_ID+'/' 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_path=os.path.join(self.G_WORK_RENDER_TASK,'photon','source',self.G_CG_OPTION) photon_user_path = os.path.join(self.G_TEMP_PATH, 'photon', self.G_CG_OPTION) # photon_user_path2=os.path.join(self.G_INPUT_PROJECT_PATH,'photon',self.G_TASK_ID) self.G_DEBUG_LOG.info(photon_path) self.G_DEBUG_LOG.info(photon_user_path) # self.G_DEBUG_LOG.info(photon_user_path2) # if os.path.exists(photon_user_path2): # copy_vrmap_cmd=r'c:\fcopy\FastCopy.exe /speed=full /force_close /no_confirm_stop /force_start "'+os.path.join(photon_user_path2,r'*.vrmap')+'" /to="'+photon_path+'"' # CLASS_COMMON_UTIL.cmd(copy_vrmap_cmd,my_log=self.G_DEBUG_LOG) if os.path.exists(photon_user_path): #photon_user_path=self.argsmap['inputDataPath']+self.G_USERID_PARENT+"/"+self.G_USERID+"/photon/"+self.G_TASK_ID+"/*.vrmap" copy_vrmap_cmd = r'c:\fcopy\FastCopy.exe /speed=full /force_close /no_confirm_stop /force_start "' + photon_user_path + '\\*.vrmap" /to="' + photon_path + '"' # CLASS_COMMON_UTIL.cmd(copy_vrmap_cmd,my_log=self.G_DEBUG_LOG) CLASS_COMMON_UTIL.cmd_python3(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) self.format_log('拷贝小光子结束', 'end') #-----------------------------------------merge photon----------------------------------------------- self.G_DEBUG_LOG.info('[Merge.RB_RENDER start]') self.merge_photon(photon_path) # self.G_KAFKA_MESSAGE_DICT['end_time']=str(int(time.time())) self.G_FEE_PARSER.set('render', 'end_time', str(int(time.time())))
def RB_MAP_DRIVE(self): #2.chongxie self.format_log('[映射盘符]', '[start]') self.G_DEBUG_LOG.info('[c4d.RB_MAP_DRIVE.start.....]') if self.G_RENDER_OS != '0': #delete all mappings CLASS_COMMON_UTIL.del_net_use() CLASS_COMMON_UTIL.del_subst() #net use b_flag = False if self.G_CG_NAME == 'C4d': map_root = os.path.basename(self.G_INPUT_PROJECT_PATH) print(map_root + '@KANADAmmmmmm') map_dict = os.path.join(self.G_INPUT_PROJECT_PATH) print(map_root + '@@KANADAnnnnnn') map_cmd = 'net use %s: "%s"' % (map_root, map_dict) CLASS_COMMON_UTIL.cmd_python3(map_cmd, my_log=self.G_DEBUG_LOG) # #base RB_MAP_DRIVE # if self.G_CG_NAME != 'Max' and self.G_TASK_JSON_DICT['system_info'].has_key('mnt_map'): # map_dict = self.G_TASK_JSON_DICT['system_info']['mnt_map'] # for key,value in map_dict.items(): # value = os.path.normpath(value) # map_cmd = 'net use "%s" "%s"' % (key,value) # CLASS_COMMON_UTIL.cmd_python3(map_cmd,my_log=self.G_DEBUG_LOG) # if key.lower() == 'b:': # b_flag = True if not b_flag: map_cmd_b = 'net use B: "%s"' % (os.path.normpath( self.G_PLUGIN_PATH)) CLASS_COMMON_UTIL.cmd(map_cmd_b, my_log=self.G_DEBUG_LOG, try_count=3) self.G_DEBUG_LOG.info('[c4d.RB_MAP_DRIVE.end.....]') self.format_log('done', 'end')
def merge_photon(self, path): self.temp_mark = self.temp_mark + 1 # self.G_DEBUG_LOG.info('photon path tempMark='+str(self.temp_mark)) # self.temp=os.path.join(self.G_WORK_RENDER_TASK,'photon','temp') # self.G_DEBUG_LOG.info('photon path temp='+self.temp) # self.RvMakeDirs(self.temp) # if not os.path.exists(self.temp): # os.makedirs(self.temp) # self.output=self.RvMakeDirs(self.temp+str(self.temp_mark)) # self.RvMakeDirs(self.output) photon_output = os.path.join(self.G_WORK_RENDER_TASK, 'photon', 'temp' + str(self.temp_mark)) # if self.G_MULTI_CAMERA: # photon_output = os.path.join(self.G_WORK_RENDER_TASK,'photon',self.G_CG_OPTION,'temp'+str(self.temp_mark)) if not os.path.exists(photon_output): os.makedirs(photon_output) self.G_DEBUG_LOG.info('photon output path=' + photon_output) render_output = self.G_WORK_RENDER_TASK_OUTPUT self.G_DEBUG_LOG.info('render output path=' + render_output) # oldRenderer=self.argsmap['render'] # self.G_DEBUG_LOG.info('oldRenderer='+oldRenderer) # standRender=oldRenderer.lower().replace("v-ray", "vray").replace("v_ray", "vray").replace("_adv__", "").replace("_adv_", "").replace("_",".").replace("demo ", "").replace(" ", "") # self.G_DEBUG_LOG.info('standRender='+standRender) if self.G_CG_CONFIG_DICT.has_key('plugins') and self.G_CG_CONFIG_DICT[ 'plugins'].has_key('vray'): stand_render = 'vray' + self.G_CG_CONFIG_DICT['plugins']['vray'] # vray='b:/plugins/max/imv/'+stand_render+'/imapviewer.exe' vray = os.path.join(self.G_MAX_B, 'imv', stand_render, 'imapviewer.exe') self.G_DEBUG_LOG.info('vray=' + vray) file_array = self.filter_photon_file(path) file_array.sort() self.G_DEBUG_LOG.info(file_array) number = len(file_array) self.G_DEBUG_LOG.info('number=' + str(number)) # print 'number='+str(number) if number <= 10: cmd = '"' + vray + '"' for p in file_array: cmd = cmd + ' -load ' + path + '/' + p pass cmd = cmd + ' -save ' + render_output + '/' + self.G_SMALL_TASK_ID + '_irrmap.vrmap -nodisplay ' # self.RVCmd(cmd) # CLASS_COMMON_UTIL.cmd(cmd,my_log=self.G_DEBUG_LOG) CLASS_COMMON_UTIL.cmd_python3(cmd, my_log=self.G_DEBUG_LOG) self.show_path_file(render_output) pass elif number > 10: j = 0 k = 0 while j < number: k = k + 1 i = 0 cmd = '"' + vray + '"' while i < 10: if j == number: break # print 'file_array['+str(j)+']='+file_array[j] self.G_DEBUG_LOG.info('file_array[' + str(j) + ']=' + file_array[j]) cmd = cmd + ' -load ' + path + '/' + file_array[j] i = i + 1 j = j + 1 pass cmd = cmd + ' -save ' + photon_output + '/' + str( k) + '.vrmap ' + ' -nodisplay' # self.RVCmd(cmd) # CLASS_COMMON_UTIL.cmd(cmd,my_log=self.G_DEBUG_LOG) CLASS_COMMON_UTIL.cmd_python3(cmd, my_log=self.G_DEBUG_LOG) # print 'j='+str(j) self.G_DEBUG_LOG.info('j=' + str(j)) self.show_path_file(photon_output) self.merge_photon(photon_output) pass