Пример #1
0
    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'
            sp_path = 'render_data'
            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)
                
            self.rendering_copy_notify()
            
            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('/','\\')+'"'
            
            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)
            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.....]')
Пример #2
0
    def AnalyzeCallBack(self):
        # to Analyse
        self.LogsCreat("AnalyzeCallBack start...")
        if self._plant == "win":
            hython = "hython.exe"
        elif self._plant == "Linux":
            hython = "hython"
            source = "%s/function/source.sh" % self._code_base_path
            source_cmd = '%s "%s/%s"' % (source, self._houdini_client_dir,
                                         self._hfs_version)
            print(source_cmd)
            os.system(source_cmd)
        # cmds
        softCmd = self._houdini_client_dir + "/" + self._hfs_version + "/bin/%s" % hython
        renderPy = r' %s/script/analyse.py ' % self._code_base_path
        renderproject = '-project "%s"' % self._hip_file
        renderGPU = ' -GPU 1'
        renderout = ' -outdir "%s"' % self._task_folder
        plugindir = ' -plugindir "%s"' % self._houdini_PLuing_dirt
        cust_id = ' -custid %s' % self.user_id

        renderCmd = softCmd + renderPy + renderproject + renderGPU + renderout + plugindir + cust_id
        self.LogsCreat("Cmds: %s" % renderCmd)
        self.LogsCreat("Houdini AnalyzeCallBack process start...")
        self.LogsCreat("...\n")
        self.LogsCreat("Loading Houdini software...")
        # Anacmdcode=subprocess.Popen(renderCmd,stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
        returncode, final_info = CLASS_COMMON_UTIL.cmd(renderCmd, None, 1,
                                                       True, True,
                                                       self.FiltLog)

        if not returncode == 0:
            self._Killapps.append("hython.exe")
            self._run_code_result = False
            self._erorr_code = 'AnalyzeCallBack process'
            self._erorr_code_info = final_info

        self.LogsCreat("[Finished.]", True, False)
        self.LogsCreat("RenderChildren return:" + str(returncode))
        self.LogsCreat("Function end.")
Пример #3
0
 def RB_HAN_FILE(self):#3  copy max.7z and so on
     self.format_log('拷贝脚本文件','start')
     self.G_DEBUG_LOG.info('[RenderMax.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)
     
     if int(self.G_CG_TILE_COUNT)>1 and self.G_CG_TILE_COUNT==self.G_CG_TILE:#merge Pic
         self.G_RENDER_WORK_TASK_BLOCK=os.path.join(self.G_RENDER_WORK_TASK,'block').replace('/','\\')
         
         block_path1=os.path.join(self.G_TEMP_PATH,self.G_TASK_ID,'block').replace('/','\\')
         self.G_DEBUG_LOG.info(block_path1)
         if not os.path.exists(block_path1):
             CLASS_COMMON_UTIL.error_exit_log(self.G_DEBUG_LOG,'block not exists in temp folder')
         copy_block_cmd='c:\\fcopy\\FastCopy.exe   /speed=full /force_close  /no_confirm_stop /force_start "'+block_path1+'\\*.*" /to="'+self.G_RENDER_WORK_TASK_BLOCK.replace('/','\\')+'"'
         # copy_block_cmd=copy_block_cmd.encode(sys.getfilesystemencoding())
         CLASS_COMMON_UTIL.cmd(copy_block_cmd,my_log=self.G_DEBUG_LOG)
     else:
     
         #----------------copy max 7z-------------------
         max_7z=os.path.join(self.G_TEMP_PATH,'max.7z')
         if not os.path.exists(max_7z):
             CLASS_COMMON_UTIL.error_exit_log(self.G_DEBUG_LOG,'max.7z not exists in temp folder')
         copy_max_7z_cmd='c:\\fcopy\\FastCopy.exe /cmd=diff /speed=full /force_close  /no_confirm_stop /force_start "'+max_7z.replace('/','\\')+'" /to="'+self.G_WORK_RENDER_TASK_MAX.replace('/','\\')+'"'
         self.G_DEBUG_LOG.info(copy_max_7z_cmd)
         # CLASS_COMMON_UTIL.cmd(copy_max_7z_cmd.encode(sys.getfilesystemencoding()),my_log=self.G_DEBUG_LOG,my_shell=True)
         CLASS_COMMON_UTIL.cmd(copy_max_7z_cmd,my_log=self.G_DEBUG_LOG,my_shell=True)
         node_max_7z=os.path.join(self.G_WORK_RENDER_TASK_MAX,'max.7z')
         if not os.path.exists(node_max_7z):
             CLASS_COMMON_UTIL.error_exit_log(self.G_DEBUG_LOG,('max.7z not exists in '+self.G_WORK_RENDER_TASK_MAX))
         
         #----------------send cmd to node-------------------
         self.vray_distribute_node()
         
         #------------------unpack max.7z----------------
         self.G_DEBUG_LOG.info('unpack 7z...')
         unpack_cmd=self.G_DRIVERC_7Z+' x "'+node_max_7z+'" -y -aos -o"'+self.G_WORK_RENDER_TASK_MAX+'"' 
         self.G_DEBUG_LOG.info(unpack_cmd)
         # CLASS_COMMON_UTIL.cmd(unpack_cmd.encode(sys.getfilesystemencoding()),my_log=self.G_DEBUG_LOG,my_shell=True)
         CLASS_COMMON_UTIL.cmd(unpack_cmd,my_log=self.G_DEBUG_LOG,my_shell=True)
         
         #----------------copy photon-------------------
         self.copy_photon()
         
     self.G_DEBUG_LOG.info('[RenderMax.RB_HAN_FILE.end.....]')
     self.format_log('done','end')
Пример #4
0
    def execute(self):  #4
        #>>> 01.检测参数之cgfile是否存在 20180523update
        #input_cgfile = os.path.normpath(self.G_INPUT_CG_FILE)
        print(self.cgfile + ' ccccccccccc')
        if not os.path.exists(self.cgfile):
            print('Error: the input cg_file is not exists or damaged!!!!')
            #sys.stdout.flush()
            time.sleep(5)
            #cgfile不存在就杀进程
            """ kill all c4d process """
            node_py_cg = r'C:\script\new_py\CG\C4d\function'
            kill_command = node_py_cg + r'\taskkill.exe /F /IM "CINEMA 4D 64 Bit.exe"'
            print(kill_command)
            #os.system(kill_command)
            print('CINEMA 4D 64 Bit.exe ended!!!')
            return
        else:
            print('loading input cgfile success~~~')

        #01.remove RBAnalyzer.pyp
        C4dLoader.remove_pyp_script(self.cgver)
        #02. update pyp & run c4d.exe
        self.__update_pyp_script()

        #03.run c4d
        c4d_cmdline = r'"C:\Program Files\MAXON\%s\CINEMA 4D 64 Bit.exe" -task_id=%s -cg_file="%s" -task_json="%s" -asset_json="%s" -tips_json="%s" -auto_commit="%s"' \
            % (self.cgver, self.taskid, self.cgfile, self.taskjson, self.assetjson, self.tipsjson, self.autocommit)
        print('Cmds: ' + c4d_cmdline)
        try:
            #prog = subprocess.Popen(c4d_cmdline, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
            prog = CLASS_COMMON_UTIL.cmd(c4d_cmdline)
            #out, err = prog.communicate()
            #print(out, err)
            print('AAAAAAAAAAAAA')
        except:
            print('subprocess CINEMA 4D 64 Bit.exe failed...')
Пример #5
0
    def AnalyzeCallBack(self):
        # to Analyse
        self.LogsCreat("AnalyzeCallBack start...")
        if self._plant == "win":
            exepro = "keyshot.exe"
        elif self._plant == "Linux":
            pass
        # cmds
        softCmd = '"%s/KeyShot%s/bin/%s" -script ' % (
            self._keyshot_client_dir, self._keyshot_version[:1], exepro)
        renderPy = r' %s/script/analyse.py ' % self._code_base_path
        renderproject = '-project "%s"' % self._bip_file
        renderout = ' -outdir "%s"' % self._task_folder
        plugindir = ' -plugindir "%s"' % self._keyshot_PLuing_dirt
        cust_id = ' -custid %s' % self.user_id

        renderCmd = softCmd + renderPy + renderproject + renderout + plugindir + cust_id
        self.LogsCreat("Cmds: %s" % renderCmd)
        self.LogsCreat("Keyshot AnalyzeCallBack process start...")
        self.LogsCreat("...\n")
        self.LogsCreat("Loading Keyshot software...")
        # Anacmdcode=subprocess.Popen(renderCmd,stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)

        returncode, final_info = CLASS_COMMON_UTIL.cmd(renderCmd, None, 1,
                                                       True, True,
                                                       self.FiltLog)

        if not returncode == 0:
            self._Killapps.append("keyshot.exe")
            self._run_code_result = False
            self._erorr_code = 'AnalyzeCallBack process'
            self._erorr_code_info = final_info

        self.LogsCreat("[Finished.]", True, False)
        self.LogsCreat("RenderChildren return:" + str(returncode))
        self.LogsCreat("Function end.")
Пример #6
0
 def send_cmd_to_node(self,thread_name,local_ip,node_ip):
     self.G_DEBUG_LOG.info("%s begin: %s\n" % (thread_name,time.ctime(time.time())))
     
     from_addr = os.path.join(self.G_SCRIPT_POOL,'CG','Max','function','MaxDistribute.py')
     from_addr2 = os.path.join(self.G_SCRIPT_POOL,'CG','Max','function','MaxPlugin.py')
     to_addr = os.path.normpath('\\\\' + node_ip + '\\' + self.G_NODE_PY.replace(':','$'))
     
     copy_node_script_path='xcopy /Y /V /F "%s" "%s"' % (from_addr,to_addr)
     copy_node_script_path2='xcopy /Y /V /F "%s" "%s"' % (from_addr2,to_addr)
     if not os.path.exists(to_addr):
         os.makedirs(to_addr)
     CLASS_COMMON_UTIL.cmd(copy_node_script_path,my_log=self.G_DEBUG_LOG)
     CLASS_COMMON_UTIL.cmd(copy_node_script_path2,my_log=self.G_DEBUG_LOG)
     
     node_script_path = os.path.join(self.G_NODE_PY,'MaxDistribute.py')
     run_node_py_cmd='B:/tools/munu_agent_controller.exe %s 10001 "C:\\Python27\\python.exe %s "%s" "%s" "%s" "c:\\log""' % (node_ip,node_script_path,self.PLUGIN_PATH,self.G_TASK_ID,local_ip)
     CLASS_COMMON_UTIL.cmd(run_node_py_cmd,my_log=self.G_DEBUG_LOG)
     
     self.G_DEBUG_LOG.info("%s over: %s\n" % (thread_name,time.ctime(time.time())))
Пример #7
0
        if os.path.exists(my_temp_vray_log):
            try:
                os.remove(my_temp_vray_log)
            except Exception, e:
                self.G_DEBUG_LOG.info(e)

        #----------Customer 3dsmax.ini----------
        try:
            if os.path.exists(max_ini) and os.path.exists(max_enu):
                copy_max_ini_cmd = 'xcopy /y /v /f "' + max_ini + '" "' + max_enu.replace(
                    '\\', '/') + '/"'
            if os.path.exists(max_user_ini) and os.path.exists(max_enu):
                copy_max_ini_cmd = 'xcopy /y /v /f "' + max_user_ini + '" "' + max_enu.replace(
                    '\\', '/') + '/"'
            self.G_DEBUG_LOG.info(copy_max_ini_cmd)
            CLASS_COMMON_UTIL.cmd(copy_max_ini_cmd, my_log=self.G_DEBUG_LOG)
        except Exception, e:
            self.G_DEBUG_LOG.info('[err].3dsmaxIni Exception')
            self.G_DEBUG_LOG.info(e)

        #------------CurrentDefaults.ini----------
        default_max = os.path.join(max_enu, 'en-US/defaults/MAX').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':
            default_max = os.path.join(max_enu, 'defaults/MAX').replace(
                '\\', '/') + '/'
        if self.G_TASK_JSON_DICT['scene_info_render']['common'].has_key(
                'gamma'):
            current_default_ini_gamma = os.path.join(
                self.G_MAX_B, 'ini/3dsmaxDefault/gammaOn', self.G_CG_VERSION,
                'CurrentDefaults.ini').replace('\\', '/')
Пример #8
0
    def RB_RENDER(self):
        self.G_DEBUG_LOG.info('[maya.RBanalyse.start.....]')
        options = {}
        options["user_id"] = self.G_USER_ID
        options["task_id"] = self.G_TASK_ID
        options["cg_project"] = self.G_INPUT_PROJECT_PATH
        options["cg_file"] = self.G_INPUT_CG_FILE
        options["task_json"] = self.G_TASK_JSON
        options["asset_json"] = self.G_ASSET_JSON
        options["tips_json"] = self.G_TIPS_JSON
        options["cg_version"] = self.CG_VERSION
        options["cg_plugins"] = self.G_CG_CONFIG_DICT["plugins"]
        print("99999999999")
        self.G_DEBUG_LOG.info(options)
        mayabatch = ["C:/Program Files/Autodesk/Maya%s/bin/mayabatch.exe" % \
                     (options["cg_version"]),
                     "D:/Program Files/Autodesk/Maya%s/bin/mayabatch.exe" % \
                     (options["cg_version"]),
                     "E:/Program Files/Autodesk/Maya%s/bin/mayabatch.exe" % \
                     (options["cg_version"]),
                     "F:/Program Files/Autodesk/Maya%s/bin/mayabatch.exe" % \
                     (options["cg_version"]),
                     "D:/Alias/Maya%sx64/bin/mayabatch.exe" % (options["cg_version"])]

        mayabatch = [i for i in mayabatch if os.path.isfile(i)]
        if mayabatch:
            mayabatch = mayabatch[0]
        else:
            print("there no Maya%s" % options["cg_version"])
            sys.exit(555)

        if self.G_RENDER_OS == '0':
            mayabatch = '/usr/autodesk/' + self.G_CG_VERSION + '-x64/bin/mayabatch.exe'
            if not os.path.exists(mayabatch):
                mayabatch = '/usr/autodesk/' + self.G_CG_VERSION + '/bin/mayabatch.exe'

        mayabatch = mayabatch.replace('\\', '/')
        # self.G_AN_MAYA_FILE=os.path.join(self.G_NODE_MAYASCRIPT,'Analyze.py').replace('\\','/')
        # analyse_cmd = "%s %s --ui %s --ti %s --proj %s --cgfile %s --taskjson %s --assetjson %s --tipsjson %s" %(mayaExePath,self.G_AN_MAYA_FILE,self.G_USER_ID,self.G_TASK_ID,self.G_INPUT_PROJECT_PATH,self.G_INPUT_CG_FILE,self.G_TASK_JSON,self.G_ASSET_JSON,self.G_TIPS_JSON)
        # print analyse_cmd
        str_options = re.sub(r"\\\\", r"/", repr(options))
        str_dir = self.G_NODE_MAYASCRIPT.replace("\\", "/")
        analyse_cmd = "\"%s\" -command \"python \\\"options=%s;" \
              "import sys;sys.path.insert(0, '%s');import Analyze;reload(Analyze);" \
              "Analyze.analyze_maya(options)\\\"" % \
              (mayabatch, str_options, str_dir)

        print(analyse_cmd)
        self.G_FEE_PARSER.set('render', 'start_time', str(int(time.time())))
        self.G_DEBUG_LOG.info(
            "\n\n-------------------------------------------Start maya program-------------------------------------\n\n"
        )
        # analyse_cmd = analyse_cmd.encode(sys.getfilesystemencoding())
        print("analyse cmd info:\n")
        self.G_DEBUG_LOG.info(analyse_cmd)
        analyze_code, analyze_result = CLASS_COMMON_UTIL.cmd(
            analyse_cmd,
            my_log=self.G_DEBUG_LOG,
            continue_on_error=True,
            my_shell=True,
            callback_func=self.maya_cmd_callback)
        print(analyze_code, analyze_result)
        print(self.tips_info_dict)
        if self.tips_info_dict:
            self.write_tips_info()
            self.G_DEBUG_LOG.info("write tips info_2 ok.")
        CLASS_MAYA_UTIL.kill_lic_all(my_log=self.G_DEBUG_LOG)
        self.G_FEE_PARSER.set('render', 'end_time', str(int(time.time())))
        self.G_DEBUG_LOG.info('[maya.RBanalyse.end.....]')
Пример #9
0
    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.....]')
Пример #10
0
    def RB_RENDER(self):  #5

        self.format_log('渲染', 'start')
        if int(self.G_CG_TILE_COUNT) != int(self.G_CG_TILE):
            self.G_DEBUG_LOG.info('[RenderMaya.RB_RENDER.start.....]')
            # if self.PRE_DICT == None:
            # render_cmd = self.MAYA_FINAL_RENDER_CMD

            # elif self.PRE_DICT['RENDER_CMD']:
            # render_cmd = self.PRE_DICT['RENDER_CMD']
            # print ("The custom render cmd: ")
            # print (render_cmd)

            # else:
            # render_cmd = self.MAYA_FINAL_RENDER_CMD

            # ------------get render cmd----------
            render_cmd = self.MAYA_FINAL_RENDER_CMD
            sys.stdout.flush()
            self.G_DEBUG_LOG.info(render_cmd)

            start_time = int(time.time())
            if self.g_one_machine_multiframe is True:
                render_list = CLASS_COMMON_UTIL.need_render_from_frame(
                    self.G_CG_FRAMES)
                self.render_record.update({
                    render_list[0]: {
                        'start_time': start_time,
                        'end_time': 0
                    }
                })
                pass
            self.G_FEE_PARSER.set('render', 'start_time', str(start_time))

            self.G_DEBUG_LOG.info(
                "\n\n-------------------------------------------Start maya program-------------------------------------\n\n"
            )
            result_code, _ = CLASS_COMMON_UTIL.cmd(
                render_cmd,
                my_log=self.G_RENDER_LOG,
                continue_on_error=True,
                my_shell=True,
                callback_func=self.maya_cmd_callback)

            self.cg_return_code = result_code
            end_time = int(time.time())
            self.G_FEE_PARSER.set('render', 'end_time', str(end_time))

            # if self.g_one_machine_multiframe is True:
            #     CLASS_MAYA_UTIL.clean_dir(self.G_WORK_RENDER_TASK_OUTPUT, my_log=self.G_DEBUG_LOG)

            CLASS_MAYA_UTIL.kill_lic_all(my_log=self.G_DEBUG_LOG)
            self.G_FEE_PARSER.set('render', 'end_time', str(end_time))
            self.G_DEBUG_LOG.info('[RenderMaya.RB_RENDER.end.....]')

        else:
            self.G_DEBUG_LOG.info('[RenderNuke.RB_RENDER.start.....]')
            self.G_FEE_PARSER.set('render', 'start_time',
                                  str(int(time.time())))
            options = {}
            options["func_path"] = self.G_NODE_MAYAFUNCTION
            options["tiles"] = int(self.G_CG_TILE_COUNT)
            options["tile_index"] = int(self.G_CG_TILE)
            options["width"] = int(self.G_TASK_JSON_DICT['scene_info_render'][
                self.G_CG_LAYER_NAME]['common']['width'])
            options["height"] = int(self.G_TASK_JSON_DICT['scene_info_render'][
                self.G_CG_LAYER_NAME]['common']['height'])
            options["output"] = self.G_WORK_RENDER_TASK_OUTPUT
            options["g_tiles_path"] = self.G_TILES_PATH
            options["g_task_id"] = self.G_TASK_ID
            options["g_cg_start_frame"] = self.G_CG_START_FRAME
            print(options)
            nuke_merge = NukeMerge(options)
            nuke_merge.render(self.G_DEBUG_LOG)
            CLASS_MAYA_UTIL.kill_lic_all(my_log=self.G_DEBUG_LOG)
            self.G_FEE_PARSER.set('render', 'end_time', str(int(time.time())))
            self.G_DEBUG_LOG.info('[RenderNuke.RB_RENDER.end.....]')

        self.format_log('done', 'end')
Пример #11
0
    def RB_CONFIG(self):
        self.format_log('渲染配置','start')
        self.G_DEBUG_LOG.info('[RenderMax.RB_CONFIG.start.....]')
        
        CLASS_MAX_UTIL.killMaxVray(self.G_DEBUG_LOG)  #kill 3dsmax.exe,3dsmaxcmd.exe,vrayspawner*.exe
        
        #----------------start grab_service-------------------
        grabServer=r'C:/work/munu_client/grab_service/grab_service.exe'
        self.G_DEBUG_LOG.info(grabServer)        
        if os.path.exists(grabServer) and CLASS_MAX_UTIL.checkProcess('grab_service'):
            self.G_DEBUG_LOG.info('start grab_service')
            os.system('start '+grabServer)

        #----------------check config file-------------------
        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':
            self.G_MAX_SCRIPT_NAME='rendera1.3.ms'
        else:
            self.G_MAX_SCRIPT_NAME='renderu1.3.ms'            
        self.G_DEBUG_LOG.info('maxscriptName------'+self.G_MAX_SCRIPT_NAME)        
        custom_script_path=os.path.join(self.G_MAX_SCRIPT,'user',self.G_USER_ID)
        custom_ms=os.path.join(custom_script_path,self.G_MAX_SCRIPT_NAME)
        custom_bat=os.path.join(custom_script_path,self.G_CUSTOM_BAT_NAME)
        max_ini=os.path.join(self.G_MAX_B,'ini','3dsmax',self.G_CG_VERSION,'3dsmax.ini')
        max_user_ini=os.path.join(self.G_MAX_B,'ini','3dsmax',self.G_USER_ID,self.G_CG_VERSION,'3dsmax.ini')
        user_host_file=os.path.join(custom_script_path,self.G_USER_HOST_NAME)
        net_render_txt=os.path.join(self.G_MAX_SCRIPT,'user',self.G_USER_ID,'netrender.txt')        
        config_file_list=[custom_script_path,custom_ms,custom_bat,max_ini,max_user_ini,user_host_file,net_render_txt]
        self.check_config_file(config_file_list)
        
        #----------------load max plugin-------------------
        self.G_DEBUG_LOG.info('插件配置')
        max_plugin=MaxPlugin(self.G_CG_CONFIG_DICT,self.G_DEBUG_LOG)
        max_plugin.config()
        
        #----------------write vray_dr.cfg-------------------
        self.vray_distribute_root()        
        
        #----------------subst path------------------
        if not os.path.exists(net_render_txt):
            self.subst_path()
            
        #-----------render.ms--------
        self.G_RAYVISION_MAX_MS=os.path.join(self.G_MAX_SCRIPT,self.G_MAX_SCRIPT_NAME).replace('\\','/')
        if os.path.exists(custom_ms):
            self.G_RAYVISION_MAX_MS=custom_ms
            
        #----------delete max log----------
        user_profile=os.environ["userprofile"]
        max_enu=user_profile+'\\AppData\\Local\\Autodesk\\3dsMax\\'+self.G_CG_VERSION.replace('3ds Max ','')+' - 64bit\\enu'
        max_log=max_enu+'\\Network\\Max.log'        
        self.G_DEBUG_LOG.info(max_log)
        if os.path.exists(max_log):
            try:
                os.remove(max_log)
            except Exception as e:
                self.G_DEBUG_LOG.info(e)
        
        #----------delete vary log----------
        user_temp_file=os.environ["temp"]
        my_temp_vray_log=os.path.join(user_temp_file,'vraylog.txt').replace('\\','/')
        self.G_DEBUG_LOG.info(my_temp_vray_log)
        if os.path.exists(my_temp_vray_log):
            try:
                os.remove(my_temp_vray_log)
            except Exception as e:
                self.G_DEBUG_LOG.info(e)
                
        #----------Customer 3dsmax.ini----------
        try:            
            if os.path.exists(max_ini) and os.path.exists(max_enu) :
                copy_max_ini_cmd='xcopy /y /v /f "'+max_ini +'" "'+max_enu.replace('\\','/')+'/"'             
            if os.path.exists(max_user_ini) and os.path.exists(max_enu) :
                copy_max_ini_cmd='xcopy /y /v /f "'+max_user_ini +'" "'+max_enu.replace('\\','/')+'/"' 
            self.G_DEBUG_LOG.info(copy_max_ini_cmd)
            CLASS_COMMON_UTIL.cmd(copy_max_ini_cmd,my_log=self.G_DEBUG_LOG)
        except Exception as e:
            self.G_DEBUG_LOG.info('[err].3dsmaxIni Exception')
            self.G_DEBUG_LOG.info(e)            
        
        #------------CurrentDefaults.ini----------
        default_max=os.path.join(max_enu,'en-US/defaults/MAX').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':
            default_max=os.path.join(max_enu,'defaults/MAX').replace('\\','/')+'/'
        if 'gamma' in self.G_TASK_JSON_DICT['scene_info_render']['common']:
            current_default_ini_gamma=os.path.join(self.G_MAX_B,'ini/3dsmaxDefault/gammaOn',self.G_CG_VERSION,'CurrentDefaults.ini').replace('\\','/')
            if self.G_TASK_JSON_DICT['scene_info_render']['common']['gamma'] == 'off':
                current_default_ini_gamma=os.path.join(self.G_MAX_B,'ini/3dsmaxDefault/gammaOff',self.G_CG_VERSION,'CurrentDefaults.ini').replace('\\','/')
            
            self.G_DEBUG_LOG.info('---current_default_ini_gamma---')
            self.G_DEBUG_LOG.info(current_default_ini_gamma)
            if os.path.exists(current_default_ini_gamma):
                copy_default_max_ini_cmd='xcopy /y /v /f "'+current_default_ini_gamma +'" "'+default_max+'"' 
                self.G_DEBUG_LOG.info(copy_default_max_ini_cmd)
                CLASS_COMMON_UTIL.cmd(copy_default_max_ini_cmd,my_log=self.G_DEBUG_LOG)

        #------------custom.bat----------
        if os.path.exists(custom_bat):
            custom_cmd=custom_bat+' "'+self.G_USER_ID+'" "'+self.G_TASK_ID+'" '
            self.G_DEBUG_LOG.info('执行custom.bat定制脚本')
            CLASS_COMMON_UTIL.cmd(custom_cmd,my_log=self.G_DEBUG_LOG)
            
        #------------host----------
        self.config_host(user_host_file)
        
        #------------red shift license----------
        try:
            # self.G_DEBUG_LOG.info('environ redshift_license [email protected]')
            # os.environ['redshift_license']='[email protected]'
            self.G_DEBUG_LOG.info('environ redshift_license')
            license_env_path = os.path.join(self.G_MAX_B,'ini','config','license_env.json')
            with open(license_env_path,'r') as pl:
                pl_dict = json.load(pl)
                self.G_DEBUG_LOG.info(pl_dict)
                if 'plugins' in self.G_CG_CONFIG_DICT:
                    for plugins_key in list(self.G_CG_CONFIG_DICT['plugins'].keys()):
                        plugin_str = plugins_key + self.G_CG_CONFIG_DICT['plugins'][plugins_key]
                        if plugin_str in pl_dict:
                            env_name = pl_dict[plugin_str]["env_name"]
                            env_value = pl_dict[plugin_str]["env_value"]
                            os.environ[env_name]=env_value
        except Exception as e:
            self.G_DEBUG_LOG.info('[err].red shift license env')
            self.G_DEBUG_LOG.info(e)
        
        #------------max cmd render----------
        # maxCmdTxt=os.path.join(self.G_MAXSCRIPT,'user',self.G_USERID,'maxcmd.txt').replace('\\','/')
        max_cmd_txt=os.path.join(self.G_MAX_SCRIPT,'user',self.G_USER_ID,'maxcmd.txt')
        if os.path.exists(max_cmd_txt):
            self.MAX_CMD_RENDER=True
        if 'render_type' in self.G_TASK_JSON_DICT['miscellaneous'] and self.G_TASK_JSON_DICT['miscellaneous']['render_type'] == 'maxcmd':
            self.MAX_CMD_RENDER=True
        # if self.MAX_CMD_RENDER:
            # self.G_CG_PROCESS_FLAG = 1
        self.G_DEBUG_LOG.info('MAX_CMD_RENDER=' + str(self.MAX_CMD_RENDER))
                
        #----------------------get max file-----------------------
        self.MAX_FILE = self.get_max_file(self.G_INPUT_CG_FILE)
        
        #maxlog.txt,vray.log
        #max plugin
        #host
        #3dsmax.ini,CurrentDefaults
        #red shift license
        #custom.bat
        
        self.G_DEBUG_LOG.info('[RenderMax.RB_CONFIG.end.....]')
        self.format_log('done','end')
Пример #12
0
    def RB_RENDER(self):
        self.G_DEBUG_LOG.info('[maya.RBanalyse.start.....]')
        if self.cg_file_error == 0:
            analyse_cmd = ''
            options = {}
            options["user_id"] = self.G_USER_ID
            options["task_id"] = self.G_TASK_ID
            options["cg_project"] = self.G_INPUT_PROJECT_PATH
            options["cg_file"] = self.G_INPUT_CG_FILE
            options["task_json"] = self.G_TASK_JSON
            options["asset_json"] = self.G_ASSET_JSON
            options["tips_json"] = self.G_TIPS_JSON
            options["cg_version"] = self.CG_VERSION
            options["cg_plugins"] = self.G_CG_CONFIG_DICT["plugins"]
            options["platform"] = self.G_PLATFORM
            options["channel"] = "web"
            self.G_DEBUG_LOG.info(options)
            self.G_DEBUG_LOG.info("current os is %s" % self.G_RENDER_OS)
            if self.G_RENDER_OS == '1':
                mayabatch = ["C:/Program Files/Autodesk/Maya%s/bin/mayabatch.exe" % \
                             (options["cg_version"]),
                             "D:/Program Files/Autodesk/Maya%s/bin/mayabatch.exe" % \
                             (options["cg_version"]),
                             "E:/Program Files/Autodesk/Maya%s/bin/mayabatch.exe" % \
                             (options["cg_version"]),
                             "F:/Program Files/Autodesk/Maya%s/bin/mayabatch.exe" % \
                             (options["cg_version"]),
                             "D:/Alias/Maya%sx64/bin/mayabatch.exe" % (options["cg_version"])]
        
                mayabatch = [i for i in mayabatch if os.path.isfile(i)]
                if mayabatch:
                    mayabatch = mayabatch[0]
                else:
                    self.G_DEBUG_LOG.info("there no Maya%s" % options["cg_version"])
                    sys.exit(555)
    
            elif self.G_RENDER_OS== '0':
                mayabatch = '/usr/autodesk/maya' + self.CG_VERSION + '-x64/bin/maya'
                if not os.path.exists(mayabatch):
                    mayabatch = '/usr/autodesk/maya' + self.CG_VERSION + '/bin/maya'
            else:
                self.G_DEBUG_LOG.info("Current OS is %s" % self.G_RENDER_OS)
                sys.exit(555)
    
            mayabatch= mayabatch.replace('\\','/')
            self.G_AN_MAYA_FILE=os.path.join(self.G_NODE_MAYASCRIPT,'Analyze.py').replace('\\','/')
            
            # analyse_cmd = "%s %s --ui %s --ti %s --proj %s --cgfile %s --taskjson %s --assetjson %s --tipsjson %s" %(mayaExePath,self.G_AN_MAYA_FILE,self.G_USER_ID,self.G_TASK_ID,self.G_INPUT_PROJECT_PATH,self.G_INPUT_CG_FILE,self.G_TASK_JSON,self.G_ASSET_JSON,self.G_TIPS_JSON)
            # print analyse_cmd
            str_options = re.sub(r"\\\\", r"/", repr(options))
            str_dir = self.G_NODE_MAYASCRIPT.replace("\\", "/")
            if self.G_RENDER_OS != '0':
                analyse_cmd = "\"%s\" -command \"python \\\"options=%s;import sys;sys.path.insert(0, '%s');import Analyze;reload(Analyze);Analyze.analyze_maya(options)\\\"\"" % (mayabatch, str_options, str_dir)
            else:
                cg_project = os.path.normpath(self.G_INPUT_PROJECT_PATH).replace("\\", "/")
                cg_file = os.path.normpath(self.G_INPUT_CG_FILE).replace("\\", "/")
                task_json = os.path.normpath(self.G_TASK_JSON).replace("\\", "/")
                analyse_cmd = "\"%s\" -batch -command \"python \\\"cg_file,cg_project,task_json=\\\\\\\"%s\\\\\\\",\\\\\\\"%s\\\\\\\",\\\\\\\"%s\\\\\\\";execfile(\\\\\\\"%s\\\\\\\")\\\"\"" %(mayabatch,cg_file,cg_project,task_json,self.G_AN_MAYA_FILE)
    
            self.G_FEE_PARSER.set('render','start_time',str(int(time.time())))
            self.G_DEBUG_LOG.info("\n\n-------------------------------------------Start maya program-------------------------------------\n\n")
            self.G_DEBUG_LOG.info("analyse cmd info:\n")
            analyze_code,analyze_result=CLASS_COMMON_UTIL.cmd(analyse_cmd,my_log=self.G_DEBUG_LOG,continue_on_error=True,my_shell=True,callback_func=self.maya_cmd_callback)
            self.G_DEBUG_LOG.info(analyze_result)
            self.G_DEBUG_LOG.info(analyze_code)

        self.G_DEBUG_LOG.info(self.tips_info_dict)
        if self.tips_info_dict:
            self.write_tips_info()
            self.G_DEBUG_LOG.info("write tips info_2 ok.")
        if not os.path.exists(self.G_ASSET_JSON):
            self.write_asset_info()
            self.G_DEBUG_LOG.info("asset.json is not exist.")
            self.G_DEBUG_LOG.info("write assets info_2 ok.")
        CLASS_MAYA_UTIL.kill_lic_all(my_log=self.G_DEBUG_LOG)        
        self.G_FEE_PARSER.set('render','end_time',str(int(time.time())))
        self.G_DEBUG_LOG.info('[maya.RBanalyse.end.....]')
Пример #13
0
    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)
            self.G_DEBUG_LOG.info('dir=' + str(type(dir)))  #test
            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

                    self.G_DEBUG_LOG.info('root=' + str(type(root)))  #test
                    self.G_DEBUG_LOG.info('root=' + root)  #test
                    self.G_DEBUG_LOG.info('root=' +
                                          str(os.path.exists(root)))  #test
                    self.G_DEBUG_LOG.info('work_small_tmp_pic=' +
                                          str(type(work_small_tmp_pic)))  #test
                    self.G_DEBUG_LOG.info('work_big_pic_tmp=' +
                                          str(type(work_big_pic_tmp)))  #test
                    self.G_DEBUG_LOG.info(
                        'work_big_pic_tmp=' +
                        str(os.path.exists(work_big_pic_tmp)))  #test
                    self.G_DEBUG_LOG.info('work_big_pic_tmp=' + str(
                        os.path.exists(
                            work_big_pic_tmp.encode(
                                sys.getfilesystemencoding()))))  #test

                    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
                    self.G_DEBUG_LOG.info('convert_cmd=' + convert_cmd)  #test
                    self.G_DEBUG_LOG.info('convert_cmd=' +
                                          str(type(convert_cmd)))  #test
                    try:
                        CLASS_COMMON_UTIL.cmd(convert_cmd,
                                              my_log=self.G_DEBUG_LOG,
                                              continue_on_error=True)
                    except Exception, e:
                        self.G_DEBUG_LOG.info('parse smallPic failed-----')
                        pass
                    CLASS_COMMON_UTIL.cmd_python3(convert_cmd,
                                                  my_log=self.G_DEBUG_LOG)
                    sys.exit(0)  #test
                    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)
Пример #14
0
 def copy_7z(self):
     zip=os.path.join(self.G_PLUGIN_PATH,'tools','7-Zip')
     copy_7z_cmd=r'c:\fcopy\FastCopy.exe /speed=full /force_close /no_confirm_stop /force_start "'+zip.replace('/','\\')+'" /to="c:\\"'
     CLASS_COMMON_UTIL.cmd(copy_7z_cmd,my_log=self.G_DEBUG_LOG)  
Пример #15
0
    def merge_photon(self, path):
        self.temp_mark = self.temp_mark + 1
        photon_output = os.path.join(self.G_WORK_RENDER_TASK, 'photon',
                                     '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)

        if 'plugins' in self.G_CG_CONFIG_DICT and 'vray' in self.G_CG_CONFIG_DICT[
                'plugins']:
            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)

            # merge vrmap
            file_array = self.filter_photon_file(path, type='vrmap')
            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 0 < 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)

            # merge vrlmap
            file_array = self.filter_photon_file(path, type='vrlmap')
            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 0 < 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 + '_lightcache.vrlmap -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) + '.vrlmap ' + ' -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)
Пример #16
0
    def RB_CONFIG(self):
        self.G_DEBUG_LOG.info('[Maya.RBconfig.start.....]')
        try:
            if self.CG_VERSION == '2017':
                # os.system ("robocopy /e /ns /nc /nfl /ndl /np  \"//10.70.242.102/render_p/script/User/100000056/maya2017\"  \"C:/Program Files/Autodesk/Maya2017/scripts/others\"" )
                copy_cmd = '{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(
                        r'B:\plugins\maya_new\2017updata3').replace('/', '\\'),
                    destination=os.path.join(
                        r"C:/Program Files/Autodesk/Maya2017/scripts/others").
                    replace("/", "\\"),
                )

                CLASS_COMMON_UTIL.cmd(copy_cmd,
                                      my_log=None,
                                      try_count=3,
                                      continue_on_error=True)

        except Exception as err:
            self.G_DEBUG_LOG.infor(err)

        if self.G_CG_TILE_COUNT != self.G_CG_TILE:
            print(
                "----------------------------------------loading plugins start ------------------------------------------"
            )
            # kill maya
            CLASS_MAYA_UTIL.killMayabatch(
                self.G_DEBUG_LOG)  # kill mayabatch.exe
            # ----------------set env  -------------------
            os.environ["MAYA_UI_LANGUAGE"] = "en_US"
            os.environ['MAYA_DISABLE_CIP'] = '1'
            os.environ['MAYA_DISABLE_CLIC_IPM'] = '1'
            os.environ['MAYA_DISABLE_CER'] = '1'
            if float(self.CG_VERSION) >= 2016:
                os.environ['MAYA_OPENCL_IGNORE_DRIVER_VERSION'] = '1'
                os.environ['MAYA_VP2_DEVICE_OVERRIDE'] = 'VirtualDeviceDx11'
            if int(self.RENDER_LAYER_TYPE):
                os.environ['MAYA_ENABLE_LEGACY_RENDER_LAYERS'] = "0"
            else:
                os.environ['MAYA_ENABLE_LEGACY_RENDER_LAYERS'] = "1"
            # ----------------load maya plugin-------------------
            self.G_DEBUG_LOG.info('插件配置')
            if self.G_CG_CONFIG_DICT:
                sys.stdout.flush()
                custom_config = os.path.join(
                    self.G_NODE_MAYAFUNCTION,
                    self.G_CUSTOME_CONFIG_NAME).replace('\\', '/')
                if self.G_NODE_MAYAFUNCTION:
                    if os.path.exists(custom_config):
                        sys.stdout.flush()
                        print("custom_config is: " + custom_config)
                        sys.stdout.flush()
                    else:
                        print("Can not find the CustomConfig file: %s." %
                              custom_config)
                print("plugin path:")
                print(self.G_CG_CONFIG_DICT)
                sys.stdout.flush()
                maya_plugin = MayaPlugin(self.G_CG_CONFIG_DICT,
                                         [custom_config], self.G_USER_ID,
                                         self.G_TASK_ID, self.G_DEBUG_LOG)
                maya_plugin.config()
                sys.stdout.flush()
            print(
                "----------------------------------------loading plugins end ------------------------------------------"
            )
            self.G_DEBUG_LOG.info('[Maya.RBconfig.end.....]')

        else:
            self.G_DEBUG_LOG.info(
                "[RenderNuke  Comp...........................]")
        self.G_DEBUG_LOG.info('[RenderMaya.RB_CONFIG.end.....]')
        self.format_log('done', 'end')
Пример #17
0
    def RB_RENDER(self):
        self.format_log('render', 'start')
        self.format_log('开始渲染', 'start')

        self.G_RENDER_LOG.info('[C4D.RBrender.start.....]')

        print(
            '--------------------remove_pyp_script----------------------------'
        )

        self.G_DEBUG_LOG.info('[C4D.remove pyp.start.....]')

        cgv = self.G_CG_VERSION
        C4dLoader.remove_pyp_script(cgv)

        print(
            '--------------------remove_pyp_script----------------------------'
        )

        self.G_DEBUG_LOG.info('[C4D.remove pyp.end.....]')

        print(
            '----------------------cg_file_info------------------------------')

        cg_project_path = os.path.basename(self.G_INPUT_PROJECT_PATH)
        print(cg_project_path)
        cg_file = self.G_INPUT_CG_FILE[len(self.G_INPUT_PROJECT_PATH):]
        print(cg_file + '8888888888888')

        get_cg_file = cg_project_path + ':' + cg_file
        print(get_cg_file + '999999999999')

        print(
            '----------------------output_filename------------------------------'
        )
        cg_file_name = os.path.basename(self.G_INPUT_CG_FILE)
        get_filename = os.path.splitext(cg_file_name)
        print(get_filename)
        self.output_filename = get_filename[0]
        print(self.output_filename + '5555555555')

        print(
            '-------------------------cg_version---------------------------------'
        )

        if self.G_CG_CONFIG_DICT.has_key('cg_name'):
            cg_name = self.G_CG_CONFIG_DICT['cg_name']

        if self.G_CG_CONFIG_DICT.has_key('cg_version'):
            cg_ver = self.G_CG_CONFIG_DICT['cg_version']

        my_cg_ver = cg_name + ' ' + cg_ver
        print(my_cg_ver)
        # if my_cg_ver.endswith('.64') :
        #     my_cg_ver=my_cg_ver.replace('.64','')
        # if my_cg_ver.endswith('.32') :
        #     my_cg_ver=my_cg_ver.replace('.32','')

        print(
            '-----------------------scene_info_dict-------------------------------'
        )

        if not self.G_TASK_JSON_DICT.has_key('scene_info'):
            self.G_DEBUG_LOG.info("[ERROR]scene_info undefined...")
            return

        scene_info_common_dict = self.G_TASK_JSON_DICT['scene_info']['common']

        cmd_render_width = scene_info_common_dict['image_size']['width']
        cmd_render_height = scene_info_common_dict['image_size']['height']
        cmd_regular_image_format = scene_info_common_dict['render_format'][
            'regular_image_format']

        cmd_multipass_format = scene_info_common_dict['render_format'][
            'multi-pass_format']
        cmd_multipass = scene_info_common_dict['multi_pass']

        #cmd_output_render_format = scene_info_common_dict['render_format']['regular_image_format']

        self.G_JOB_NAME = self.G_JOB_NAME.encode(sys.getfilesystemencoding())

        print(
            '--------------------------render_info----------------------------------'
        )
        output_file = self.G_WORK_RENDER_TASK_OUTPUT.replace(
            "/", "\\") + "\\" + self.output_filename + '.' + str(
                cmd_regular_image_format)
        print(output_file + '4444444444')

        output_renderlog_file = os.path.join(self.G_LOG_WORK + '/' +
                                             self.G_TASK_ID + '\\Render_' +
                                             self.G_JOB_ID +
                                             '_render.log').replace('/', '\\')
        print(output_renderlog_file)

        c4d_exe = os.path.join(r'"C:\Program Files\MAXON', my_cg_ver,
                               'CINEMA 4D 64 Bit.exe"') + ' -noopengl -nogui'

        render_frames = ' -frame ' + self.G_CG_START_FRAME + ' ' + self.G_CG_END_FRAME + ' ' + self.G_CG_BY_FRAME + ' '

        render_option = str(render_frames) + ' -render "' + get_cg_file.replace("/", "\\") + '" -oresolution ' + str(cmd_render_width) \
         + ' ' + str(cmd_render_height) +'  -oformat "' + str(cmd_regular_image_format) + '" -oimage "' + output_file + ' -oMulti-Pass "' \
         + str(cmd_multipass) + '"'

        render_cmd = c4d_exe + render_option

        ##"C:\Program Files\MAXON\CINEMA 4D R18\CINEMA 4D 64 Bit.exe" -noopengl -nogui -frame 0 0 1 -render "F:\R18_test.c4d" -oresolution 192 108 -oformat "TGA" -oimage "c:\work\render\111\output\8888.PNG" -omultipass "c:\work\render\111\output\22222.PNG" >>C:\log\render\111\Render_111281_render.log

        #render_cmd = c4d_exe + ' -noopengl -nogui  -frame ' + self.G_CG_START_FRAME + ' ' + self.G_CG_END_FRAME + ' -render "' + cg_file.replace("/", "\\") + '" -oresolution ' + str(cmd_render_width) + ' ' + str(cmd_render_height) + ' -oformat ' + cmd_regular_image_format + ' -oimage "' + output_file + '"'
        #print (render_cmd)

        # if self.multipass == '':
        #     render_cmd = render_cmd + ' >>' + output_renderlog_file
        # if self.multipass == '1':
        #     render_cmd = render_cmd + ' -oMulti-Pass "' + output_file + '"' + ' >>' + output_renderlog_file

        #self.G_DEBUG_LOG.info('Cmd: %s' % render_cmd)
        self.G_DEBUG_LOG.info('[.HL]')
        # self.G_KAFKA_MESSAGE_DICT['startTime']=str(int(time.time()))
        self.G_FEE_PARSER.set('render', 'start_time', str(int(time.time())))

        if self.G_RENDER_OS == 'Linux':
            self.RBcmd(render_cmd, True, 1, myLog=True)
        else:

            print(
                '---------------------------------------Start c4d program---------------------------------'
            )

            CLASS_COMMON_UTIL.cmd(render_cmd,
                                  my_log=self.G_DEBUG_LOG,
                                  continue_on_error=True,
                                  my_shell=True,
                                  callback_func=self.c4d_cmd_callback)

        # self.G_KAFKA_MESSAGE_DICT['endTime']=str(int(time.time()))
        self.G_FEE_PARSER.set('render', 'end_time', str(int(time.time())))

        self.G_RENDER_LOG.info('[C4D.RBrender.end.....]')
        self.format_log('done', 'end')
        self.format_log('结束渲染', 'end')
Пример #18
0
    def RB_RENDER(self):  #5

        self.format_log('渲染', 'start')
        if int(self.G_CG_TILE_COUNT) != int(self.G_CG_TILE):
            self.G_DEBUG_LOG.info('[RenderMaya.RB_RENDER.start.....]')
            # if self.PRE_DICT == None:
            # render_cmd = self.MAYA_FINAL_RENDER_CMD

            # elif self.PRE_DICT['RENDER_CMD']:
            # render_cmd = self.PRE_DICT['RENDER_CMD']
            # print ("The custom render cmd: ")
            # print (render_cmd)

            # else:
            # render_cmd = self.MAYA_FINAL_RENDER_CMD

            # 是否一机多帧
            if self.g_one_machine_multiframe is True:
                if int(self.G_RECOMMIT_FLAG) > 0:
                    cmd = r'c:\fcopy\FastCopy.exe /cmd=force_copy /speed=full /force_close /no_confirm_stop /force_start "{}" /to="{}"'.format(
                        os.path.join(self.G_REMOTE_TASK_CFG,
                                     self.render_record_json),
                        self.G_WORK_RENDER_TASK_MULTIFRAME,
                    )
                    CLASS_COMMON_UTIL.cmd(cmd, my_log=self.G_DEBUG_LOG)
                # 监控线程
                frames = self.remain_frames()
                render_list = CLASS_COMMON_UTIL.need_render_from_frame(frames)
                t = threading.Thread(target=self.loop_handle_complete,
                                     args=(render_list, ))
                t.start()
                self.monitor_complete_thread = t

            # ------------get render cmd----------
            render_cmd = self.MAYA_FINAL_RENDER_CMD
            sys.stdout.flush()
            self.G_DEBUG_LOG.info(render_cmd)
            start_time = int(time.time())
            if self.g_one_machine_multiframe is True:
                self.render_record.update(
                    {frames[0]: {
                         'start_time': start_time,
                         'end_time': 0
                     }})
                pass
            self.G_FEE_PARSER.set('render', 'start_time', str(start_time))

            self.G_DEBUG_LOG.info(
                "\n\n-------------------------------------------Start maya program-------------------------------------\n\n"
            )
            result_code, _ = CLASS_COMMON_UTIL.cmd(
                render_cmd,
                my_log=self.G_DEBUG_LOG,
                continue_on_error=True,
                my_shell=True,
                callback_func=self.maya_cmd_callback)

            self.cg_return_code = result_code
            end_time = int(time.time())
            self.G_FEE_PARSER.set('render', 'end_time', str(end_time))

            CLASS_MAYA_UTIL.kill_lic_all(my_log=self.G_DEBUG_LOG)
            self.G_FEE_PARSER.set('render', 'end_time', str(end_time))
            self.G_DEBUG_LOG.info('[RenderMaya.RB_RENDER.end.....]')

        else:
            self.G_DEBUG_LOG.info('[RenderNuke.RB_RENDER.start.....]')
            self.G_FEE_PARSER.set('render', 'start_time',
                                  str(int(time.time())))
            options = {}
            options["func_path"] = self.G_NODE_MAYAFUNCTION
            options["tiles"] = int(self.G_CG_TILE_COUNT)
            options["tile_index"] = int(self.G_CG_TILE)
            options["width"] = int(self.G_TASK_JSON_DICT['scene_info_render'][
                self.G_CG_LAYER_NAME]['common']['width'])
            options["height"] = int(self.G_TASK_JSON_DICT['scene_info_render'][
                self.G_CG_LAYER_NAME]['common']['height'])
            options["output"] = self.G_WORK_RENDER_TASK_OUTPUT
            options["g_tiles_path"] = self.G_TILES_PATH
            options["g_task_id"] = self.G_TASK_ID
            options["g_cg_start_frame"] = self.G_CG_START_FRAME
            print(options)
            nuke_merge = NukeMerge(options)
            nuke_merge.render(self.G_DEBUG_LOG)
            CLASS_MAYA_UTIL.kill_lic_all(my_log=self.G_DEBUG_LOG)
            self.G_FEE_PARSER.set('render', 'end_time', str(int(time.time())))
            self.G_DEBUG_LOG.info('[RenderNuke.RB_RENDER.end.....]')

        self.format_log('done', 'end')
Пример #19
0
    def RB_CONFIG(self):
        """拷贝2017的mayaBatchRenderProcedure,删除mayabatch进程,设置环境变量,执行 MayaPlugin 配置插件,
        get_render_cmd 获取cmd内容 并打印."""
        self.G_DEBUG_LOG.info('[Maya.RBconfig.start.....]')
        try:
            if float(self.CG_VERSION) == 2017:
                # 拷贝mayaBatchRenderProcedure.mel
                # os.system ("robocopy /e /ns /nc /nfl /ndl /np  \"//10.70.242.102/render_p/script/User/100000056/maya2017\"  \"C:/Program Files/Autodesk/Maya2017/scripts/others\"" )
                copy_cmd = '{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(
                        r'\\10.60.100.104\new_render_data\input\p\script\User\10000036\CG\Maya\script\2017updata3'
                    ).replace('/', '\\'),
                    destination=os.path.join(
                        r"C:/Program Files/Autodesk/Maya2017/scripts/others").
                    replace("/", "\\"),
                )

                CLASS_COMMON_UTIL.cmd(copy_cmd,
                                      my_log=None,
                                      try_count=3,
                                      continue_on_error=True)

        except Exception as err:
            self.G_DEBUG_LOG.infor(err)

        # G_CG_TILE_COUNT = 分块总数 G_CG_TILE = 当前分块号码  相等的情况是合并帧任务
        if self.G_CG_TILE_COUNT != self.G_CG_TILE:
            print(
                "----------------------------------------loading plugins start ------------------------------------------"
            )
            #kill maya
            CLASS_MAYA_UTIL.killMayabatch(
                self.G_DEBUG_LOG)  #kill mayabatch.exe
            # ----------------set env  -------------------
            os.environ["MAYA_UI_LANGUAGE"] = "en_US"
            os.environ['MAYA_DISABLE_CIP'] = '1'
            os.environ['MAYA_DISABLE_CLIC_IPM'] = '1'
            os.environ['MAYA_DISABLE_CER'] = '1'
            #设置Viewport2.0
            if float(self.CG_VERSION) >= 2016:
                os.environ['MAYA_OPENCL_IGNORE_DRIVER_VERSION'] = '1'
                os.environ['MAYA_VP2_DEVICE_OVERRIDE'] = 'VirtualDeviceDx11'
            #根据平台设置渲染层模式 设置
            if int(self.RENDER_LAYER_TYPE):
                os.environ['MAYA_ENABLE_LEGACY_RENDER_LAYERS'] = "0"
            else:
                os.environ['MAYA_ENABLE_LEGACY_RENDER_LAYERS'] = "1"
            # ----------------load maya plugin-------------------
            self.G_DEBUG_LOG.info('插件配置')
            if self.G_CG_CONFIG_DICT:
                sys.stdout.flush()
                #c:\script\new_py\CG\Maya\function\C_PreRender.py
                custom_config = os.path.join(
                    self.G_NODE_MAYAFUNCTION,
                    self.G_CUSTOME_CONFIG_NAME).replace('\\', '/')
                # 在munu.log打印出 prerender路径
                if self.G_NODE_MAYAFUNCTION:
                    if os.path.exists(custom_config):
                        sys.stdout.flush()
                        print("custom_config is: " + custom_config)
                        sys.stdout.flush()
                    else:
                        print("Can not find the CustomConfig file: %s." %
                              custom_config)
                print("plugin path:")
                print(self.G_CG_CONFIG_DICT)
                sys.stdout.flush()
                #执行 MayaPlugin
                maya_plugin = MayaPlugin(self.G_CG_CONFIG_DICT,
                                         [custom_config], self.G_USER_ID,
                                         self.G_TASK_ID, self.G_DEBUG_LOG)
                maya_plugin.config()
                sys.stdout.flush()
            print(
                "----------------------------------------loading plugins end ------------------------------------------"
            )
            self.G_DEBUG_LOG.info('[Maya.RBconfig.end.....]')

            # #------------get render cmd----------
            self.MAYA_FINAL_RENDER_CMD = self.get_render_cmd()
            #打印 cmd 内容
            self.G_DEBUG_LOG.info(self.MAYA_FINAL_RENDER_CMD)
        else:
            self.G_DEBUG_LOG.info(
                "[RenderNuke  Comp...........................]")
        self.G_DEBUG_LOG.info('[RenderMaya.RB_CONFIG.end.....]')
        self.format_log('done', 'end')
Пример #20
0
    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'
            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)
                    self.G_SMALL_PIC = work_big_pic.replace(dir + '\\', '')
                    self.G_SMALL_PIC = self.G_JOB_NAME + "_" + self.G_SMALL_PIC.replace(
                        '\\', '[_]').replace('.', '[-]') + '.jpg'
                    small_tmp_name = self.G_JOB_NAME + '_tmp.jpg'
                    work_small_pic = os.path.join(work_small_path,
                                                  self.G_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)
                    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)
Пример #21
0
    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 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_TASK_ID + '_irrmap.vrmap -nodisplay '
                # self.RVCmd(cmd)
                CLASS_COMMON_UTIL.cmd(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)
                # print 'j='+str(j)
                self.G_DEBUG_LOG.info('j=' + str(j))
                self.show_path_file(photon_output)
                self.merge_photon(photon_output)
            pass
Пример #22
0
    def RB_RENDER(self):
        self.format_log('render','start')
        self.format_log('开始渲染','start')
        #start...
        self.G_RENDER_LOG.info('[c4d.RBrender.start.....]')

        #print ('--------------------remove_pyp_script----------------------------')
        
        self.G_DEBUG_LOG.info('[c4d.remove pyp.start.....]')
        
        cgv = self.G_CG_VERSION  # "CINEMA 4D R19"
        C4dLoader.remove_pyp_script(cgv)


        self.G_DEBUG_LOG.info('[c4d.remove pyp.end.....]')


        print ('----------------------cg_file_info------------------------------')
        map_dict = self.G_TASK_JSON_DICT['mnt_map']  # use "/"
        map_dict_reverse = dict(zip(map_dict.values(), map_dict.keys()))
        print('map_dict_reverse: %s' % map_dict_reverse)
        
        # G_INPUT_CG_FILE: os.path.normpath(r'//10.60.100.104/stg_data/input/d/inputdata5/10000000/10000085/c4d/R17_test_ch.c4d')
        # G_INPUT_USER_PATH: os.path.normpath(r'//10.60.100.104/stg_data/input/d/inputdata5/10000000/10000085')
        
        input_cg_file_second_half = self.G_INPUT_CG_FILE[len(self.G_INPUT_USER_PATH):]  # \E\test\C4DR17_Vray19_test\Vray_C4DR17_vray19.c4d
        print('input_cg_file_second_half: ' + input_cg_file_second_half)
        index = input_cg_file_second_half.find(os.sep, 1)  # index begin position:1
        input_cg_file_second_half_front = input_cg_file_second_half[:index]  # \E
        input_cg_file_second_half_behind = input_cg_file_second_half[index:]  # \test\C4DR17_Vray19_test\Vray_C4DR17_vray19.c4d
        print('input_cg_file_second_half_behind: ' + input_cg_file_second_half_behind)

        key = self.G_INPUT_USER_PATH + input_cg_file_second_half_front  # \\10.60.100.104\stg_data\input\d\inputdata5\10000000\10000085\E
        driver = map_dict_reverse.get(key.replace('\\', '/'))  # E:
        print('driver: %s' % driver)

        get_cg_file = driver + input_cg_file_second_half_behind  # local cg file path
        print(get_cg_file + '[.@KANADA999999999999]')

        
        print ('-------------------------cg_version---------------------------------')

        if 'cg_name' in self.G_CG_CONFIG_DICT:
            cg_name = self.G_CG_CONFIG_DICT['cg_name']

        if 'cg_version' in self.G_CG_CONFIG_DICT:
            cg_ver = self.G_CG_CONFIG_DICT['cg_version']


        my_cg_ver = cg_name + ' ' + cg_ver
        print (my_cg_ver)
        # if my_cg_ver.endswith('.64') :
        #     my_cg_ver=my_cg_ver.replace('.64','')
        # if my_cg_ver.endswith('.32') :
        #     my_cg_ver=my_cg_ver.replace('.32','')

        print ('-----------------------scene_info_render-------------------------------')

        if 'scene_info_render' not in self.G_TASK_JSON_DICT:
            self.G_DEBUG_LOG.info("[ERROR]scene_info_render undefined...")
            return

        scene_info_render_common_dict = self.G_TASK_JSON_DICT['scene_info_render']['common']

        cmd_render_width = scene_info_render_common_dict['width']
        cmd_render_height = scene_info_render_common_dict['height']
        cmd_regular_image_format = scene_info_render_common_dict['regular_image_format']
        cmd_multipass_format = scene_info_render_common_dict['multi_pass_format'] 
        cmd_multipass_path = scene_info_render_common_dict['multipass_saveimage_path']
        cmd_multipass_enabled= scene_info_render_common_dict['multipass_save_enabled']
        cmd_regular_image_saveimage_path= scene_info_render_common_dict['regular_image_saveimage_path']
        
        print ('----------------------output_filename------------------------------')
        
        if cmd_regular_image_saveimage_path is None:
            cg_file_name = os.path.basename(self.G_INPUT_CG_FILE)
            get_filename = os.path.splitext(cg_file_name)
            cmd_regular_image_saveimage_path = get_filename[0]
            print((cmd_regular_image_saveimage_path + '[.@KANADA5555555555]'))
        
        
        self.G_JOB_NAME=self.G_JOB_NAME.encode(sys.getfilesystemencoding())

        print ('--------------------------render_info----------------------------------')
        
        start_time = int(time.time())
        self.G_FEE_PARSER.set('render', 'start_time', str(start_time))
        
        if self.g_one_machine_multiframe == None or self.g_one_machine_multiframe == False:
            #C:\work\render\65368\output\0001.jpg
            output_file = self.G_WORK_RENDER_TASK_OUTPUT.replace("/", "\\") + "\\" + cmd_regular_image_saveimage_path + '.' + str(cmd_regular_image_format)
            print(output_file + '4444444444')

            output_renderlog_file = os.path.join(self.G_LOG_WORK +'/' + self.G_TASK_ID + '\\Render_' + self.G_JOB_ID + '_render.log').replace('/', '\\')
            print (output_renderlog_file)
            
            # cmd
            c4d_exe = os.path.join(r'"C:\Program Files\MAXON', my_cg_ver, 'CINEMA 4D 64 Bit.exe"') + ' -noopengl -nogui'
            user_id = ' ' + str(self.G_USER_ID)
            task_id = ' ' + str(self.G_TASK_ID) + ' '
            render_frames = ' -frame ' + self.G_CG_START_FRAME + ' ' + self.G_CG_END_FRAME  + ' '+ self.G_CG_BY_FRAME + ' '
            
            render_option = ''
            if cmd_multipass_enabled == "0" or cmd_multipass_path == None or cmd_multipass_path == "":
                render_option = render_frames + ' -render "' + get_cg_file.replace("/", "\\") + '" -oresolution "' + str(cmd_render_width) \
                            + '" "' + str(cmd_render_height) +'" -oformat "' + str(cmd_regular_image_format) + '" -oimage "' + output_file + '"'
                print('render_option1: %s'%render_option)
            else:
                render_option = render_frames + ' -render "' + get_cg_file.replace("/", "\\") + '" -oresolution "' + str(cmd_render_width) \
                            + '" "' + str(cmd_render_height) +'" -oformat "' + str(cmd_regular_image_format) + '" -oimage "' + output_file + '" -omultipass "' + output_file + '" '
                print('render_option2: %s'%render_option)

            render_cmd = c4d_exe + user_id + task_id + render_option
            #print("Cmds: %s" % render_cmd)
            self.G_RENDER_LOG.info("Cmds: %s" % render_cmd)
            
            self.G_DEBUG_LOG.info('[.@KANADA]')
            # 渲染开始时间
            render_start_time = int(time.time())
            
            if self.G_RENDER_OS=='Linux':
                self.RBcmd(render_cmd, True, 1, myLog=True)
            else:
                print ('\n\n---------------------------------------Start c4d program---------------------------------\n\n')
                CLASS_COMMON_UTIL.cmd(render_cmd,my_log=self.G_RENDER_LOG,continue_on_error=True,my_shell=True,callback_func=self.c4d_cmd_callback)

            # 渲染结束时间
            render_end_time = int(time.time())
            self.render_record[render_frames] = {'start_time': render_start_time,'end_time': render_end_time}
            
        elif self.g_one_machine_multiframe == True:
            render_frame_list = CLASS_COMMON_UTIL.need_render_from_frame(self.G_CG_FRAMES)
            for frame in render_frame_list:
                print("current rendering frame: %s" % frame)
                #C:\work\render\65368\output\0001\0001.jpg
                output_file = self.G_WORK_RENDER_TASK_OUTPUT.replace("/", "\\") + "\\" + frame.zfill(4) +"\\" + cmd_regular_image_saveimage_path + '.' + str(cmd_regular_image_format)
                print(output_file + '4444444444')
                # cmd
                c4d_exe = os.path.join(r'"C:\Program Files\MAXON', my_cg_ver, 'CINEMA 4D 64 Bit.exe"') + ' -noopengl -nogui'
                user_id = ' ' + str(self.G_USER_ID)
                task_id = ' ' + str(self.G_TASK_ID) + ' '
                render_frames = ' -frame ' + frame + ' ' + frame  + ' 1 '
                render_option = ''
                if cmd_multipass_enabled == "0" and cmd_multipass_path == None:
                    render_option = render_frames + ' -render "' + get_cg_file.replace("/", "\\") + '" -oresolution "' + str(cmd_render_width) \
                            + '" "' + str(cmd_render_height) +'" -oformat "' + str(cmd_regular_image_format) + '" -oimage "' + output_file + '"'
                    print('render_option1: %s'%render_option)
                else:
                    render_option = render_frames + ' -render "' + get_cg_file.replace("/", "\\") + '" -oresolution "' + str(cmd_render_width) \
                            + '" "' + str(cmd_render_height) +'" -oformat "' + str(cmd_regular_image_format) + '" -oimage "' + output_file + '" -omultipass "' + output_file + '" '
                    print('render_option2: %s'%render_option)

                render_cmd = c4d_exe + user_id + task_id + render_option
                #print("Cmds: %s" % render_cmd)
                self.G_RENDER_LOG.info("Cmds: %s" % render_cmd)
                
                self.G_DEBUG_LOG.info('[.@KANADA]')
                # 渲染开始时间
                render_start_time = int(time.time())

                
                if self.G_RENDER_OS == 'Linux':
                    self.RBcmd(render_cmd, True, 1, myLog=True)
                else:
                    print ('\n\n---------------------------------------Start c4d program---------------------------------\n\n')
                    CLASS_COMMON_UTIL.cmd(render_cmd,my_log=self.G_DEBUG_LOG,continue_on_error=True,my_shell=True,callback_func=self.c4d_cmd_callback)

                CLASS_COMMON_UTIL.log_print(self.G_DEBUG_LOG, ("current rendering frame: ", frame))
                # 渲染结束时间
                render_end_time = int(time.time())
                self.render_record[frame] = {'start_time': render_start_time,'end_time': render_end_time}
                
                
                self.multiframe_complete_list.append(frame)
            
            #self.G_RENDER_LOG.info('[一机多帧暂时不支持...]')
            #self.G_DEBUG_LOG.info('[一机多帧暂时不支持...]')
        
        end_time = int(time.time())
        self.G_FEE_PARSER.set('render', 'end_time', str(end_time))
        
        self.G_RENDER_LOG.info('[C4D.RBrender.end.....]')
        #end...
        os.system(r'wmic process where name="rlm.exe" delete')
        os.system(r'wmic process where name="rlm_c4dtoa.exe" delete')
        
        self.format_log('done','end')
        self.format_log('结束渲染','end')