示例#1
0
 def subst_path(self):
     self.G_DEBUG_LOG.info('[RenderMax.subst_path.start.....]')
     bat_str = ''
     for file_name in os.listdir(self.G_WORK_RENDER_TASK_MAX):
         self.G_DEBUG_LOG.info(file_name)
         if os.path.isfile(
                 os.path.join(self.G_WORK_RENDER_TASK_MAX, file_name)):
             continue
         dir_name = file_name.lower()
         dir_path = os.path.join(self.G_WORK_RENDER_TASK_MAX,
                                 file_name).lower()
         self.G_DEBUG_LOG.info(dir_name)
         if dir_name == 'net':
             continue
         if dir_name == 'default':
             continue
         if dir_name == 'b' or dir_name == 'c' or dir_name == 'd':
             continue
         #e,f,g...
         if len(dir_name) == 1:
             subst_cmd = 'subst ' + dir_name + ': "' + dir_path + '"'
             self.G_DEBUG_LOG.info(subst_cmd)
             os.system(subst_cmd)
             bat_str = bat_str + subst_cmd + '\r\n'
     bat_file = os.path.join(self.G_WORK_RENDER_TASK_CFG, 'substDriver.bat')
     CLASS_COMMON_UTIL.write_file(bat_str, bat_file)
     self.G_DEBUG_LOG.info('[RenderMax.subst_path.end.....]')
示例#2
0
    def write_ms_file(self):

        not_render = 'false'
        if self.G_CG_VERSION == '3ds Max 2012' or self.G_CG_VERSION == '3ds Max 2011' or self.G_CG_VERSION == '3ds Max 2010' or self.G_CG_VERSION == '3ds Max 2009':
            render_ms_name = 'rendera2.0.ms'
        else:
            render_ms_name = 'renderu2.0.ms'

        # render_frame = get_render_frame()

        render_ms = os.path.join(self.G_NODE_MAXSCRIPT,
                                 render_ms_name).replace('\\', '/')
        task_ms_file = os.path.join(
            self.G_WORK_RENDER_TASK_CFG,
            ('render' + self.G_CG_FRAMES + '.ms')).replace('\\', '/')

        # self.MAX_FILE=self.get_max_file(self.G_INPUT_CG_FILE)
        ms_str = '(DotNetClass "System.Windows.Forms.Application").CurrentCulture = dotnetObject "System.Globalization.CultureInfo" "zh-cn"\r\n'
        ms_str = ms_str + 'filein @"' + render_ms + '"\r\n'
        ms_str = ms_str + 'fn renderRun = (\r\n'
        ms_str = ms_str + 'web_render #("' + self.G_USER_ID + '","' + self.G_TASK_ID + '","' + not_render + '","' + self.G_CG_FRAMES + '","'
        ms_str = ms_str + self.G_ACTION_ID + '","' + self.G_CG_OPTION + '","' + self.G_ACTION + '","' + self.G_WORK_RENDER_TASK_OUTPUT.replace(
            '\\', '/') + '/' + '","' + self.MAX_FILE + '", @"'
        ms_str = ms_str + self.G_TASK_JSON.replace('\\', '/') + '"'
        ms_str = ms_str + ',"' + self.G_KG + '"'
        ms_str = ms_str + ') \r\n)'
        if self.G_CG_VERSION == '3ds Max 2012' or self.G_CG_VERSION == '3ds Max 2011' or self.G_CG_VERSION == '3ds Max 2010' or self.G_CG_VERSION == '3ds Max 2009':
            CLASS_COMMON_UTIL.write_file(ms_str, task_ms_file, my_code='utf-8')
        else:
            CLASS_COMMON_UTIL.write_file(ms_str, task_ms_file, my_code='gbk')

        self.G_DEBUG_LOG.info('[RenderMax.write_ms_file.end.....]')
        return task_ms_file
示例#3
0
    def RB_KAFKA_NOTIFY(self):  #9
        if self.G_ACTION not in ['Analyze', 'Pre']:
            self.format_log('kafka发送消息给平台', 'start')
            self.G_DEBUG_LOG.info('[BASE.RB_KAFKA_NOTIFY.start.....]')

            send_time = str(int(time.time()))
            self.G_KAFKA_MESSAGE_DICT["munu_task_id"] = self.G_MUNU_ID
            self.G_KAFKA_MESSAGE_DICT["munu_job_id"] = self.G_JOB_ID
            self.G_KAFKA_MESSAGE_DICT["recommit_flag"] = self.G_RECOMMIT_FLAG
            self.G_KAFKA_MESSAGE_DICT["action"] = self.G_ACTION
            self.G_KAFKA_MESSAGE_DICT['platform'] = self.G_PLATFORM
            self.G_KAFKA_MESSAGE_DICT['send_time'] = send_time
            self.G_KAFKA_MESSAGE_DICT['zone'] = self.G_ZONE
            self.G_KAFKA_MESSAGE_DICT['node_name'] = self.G_NODE_ID
            self.G_KAFKA_MESSAGE_DICT['task_id'] = self.G_TASK_ID
            self.G_KAFKA_MESSAGE_DICT['render_type'] = self.G_RENDER_CORE_TYPE
            #self.G_KAFKA_MESSAGE_DICT['start_time']=self.G_START_TIME
            #self.G_KAFKA_MESSAGE_DICT['big_pic']=[]
            #self.G_KAFKA_MESSAGE_DICT['small_pic']=[]
            #self.G_KAFKA_MESSAGE_DICT['end_time']=self.G_END_TIME
            #self.G_KAFKA_MESSAGE_DICT['distribute_node'] = '1'

            self.G_DEBUG_LOG.info('G_KAFKA_MESSAGE_DICT=' +
                                  str(self.G_KAFKA_MESSAGE_DICT))

            # write kafka message json file(e.g. C:\work\render\10002736\2017120500004_0_1.json)
            kafka_message_filename = self.G_MUNU_ID + '_' + self.G_JOB_ID + '.json'
            if self.G_RECOMMIT_FLAG != '':
                kafka_message_filename = self.G_MUNU_ID + '_' + self.G_JOB_ID + '_' + self.G_RECOMMIT_FLAG + '.json'
            kafka_message_json = os.path.join(self.G_WORK_RENDER_TASK,
                                              kafka_message_filename)
            kafka_message_json_str = json.dumps(self.G_KAFKA_MESSAGE_DICT,
                                                ensure_ascii=False)
            CLASS_COMMON_UTIL.write_file(kafka_message_json_str,
                                         kafka_message_json)
            CLASS_COMMON_UTIL.python_copy(kafka_message_json,
                                          self.G_CONFIG_PATH)

            try:
                kafka_result = CLASS_KAFKA.produce(self.G_KAFKA_MESSAGE_DICT,
                                                   self.G_KAFKA_SERVER,
                                                   self.G_KAFKA_TOPIC)
                self.G_DEBUG_LOG.info('kafka_result=' + str(kafka_result))
            except:
                CLASS_COMMON_UTIL.error_exit_log(self.G_DEBUG_LOG,
                                                 'Send Kafka Message Failed',
                                                 is_exit=False)

            self.G_DEBUG_LOG.info('[BASE.RB_KAFKA_NOTIFY.end.....]')
            self.format_log('done', 'end')
示例#4
0
    def RB_KAFKA_NOTIFY(self):  #9
        if self.G_ACTION not in ['Analyze', 'Pre']:
            self.format_log('kafka发送消息给平台', 'start')
            self.G_DEBUG_LOG.info('[BASE.RB_KAFKA_NOTIFY.start.....]')

            send_time = str(int(time.time()))
            self.G_KAFKA_MESSAGE_DICT["action"] = self.G_ACTION
            self.G_KAFKA_MESSAGE_DICT['platform'] = self.G_PLATFORM
            self.G_KAFKA_MESSAGE_DICT['sendTime'] = send_time
            self.G_KAFKA_MESSAGE_DICT['zone'] = self.G_ZONE
            self.G_KAFKA_MESSAGE_DICT['nodeName'] = self.G_NODE_ID
            self.G_KAFKA_MESSAGE_DICT['jobId'] = self.G_JOB_ID
            self.G_KAFKA_MESSAGE_DICT['taskId'] = self.G_TASK_ID
            self.G_KAFKA_MESSAGE_DICT['renderType'] = self.G_RENDER_CORE_TYPE
            #self.G_KAFKA_MESSAGE_DICT['startTime']=self.G_START_TIME
            #self.G_KAFKA_MESSAGE_DICT['bigPic']=[]
            #self.G_KAFKA_MESSAGE_DICT['smallPic']=[]
            #self.G_KAFKA_MESSAGE_DICT['endTime']=self.G_END_TIME
            #self.G_KAFKA_MESSAGE_DICT['distributeNode'] = '1'

            self.G_DEBUG_LOG.info('G_KAFKA_MESSAGE_DICT=' +
                                  str(self.G_KAFKA_MESSAGE_DICT))

            # write kafka message json file(e.g. C:\work\render\10002736\1849754-10002736-frame0001.json)
            # kafka_message_filename = self.G_USER_ID+'-'+self.G_TASK_ID+'-'+self.G_JOB_NAME+'.json'
            kafka_message_filename = self.G_JOB_ID + '_' + self.G_ACTION + '_' + send_time + '.json'
            kafka_message_json = os.path.join(self.G_WORK_RENDER_TASK,
                                              kafka_message_filename)
            kafka_message_json_str = json.dumps(self.G_KAFKA_MESSAGE_DICT,
                                                ensure_ascii=False)
            CLASS_COMMON_UTIL.write_file(kafka_message_json_str,
                                         kafka_message_json)
            CLASS_COMMON_UTIL.python_copy(kafka_message_json,
                                          self.G_CONFIG_PATH)

            try:
                kafka_result = CLASS_KAFKA.produce(self.G_KAFKA_MESSAGE_DICT,
                                                   self.G_KAFKA_SERVER,
                                                   self.G_KAFKA_TOPIC)
                self.G_DEBUG_LOG.info('kafka_result=' + str(kafka_result))
            except:
                CLASS_COMMON_UTIL.error_exit_log(self.G_DEBUG_LOG,
                                                 'Send Kafka Message Failed',
                                                 is_exit=False)

            self.G_DEBUG_LOG.info('[BASE.RB_KAFKA_NOTIFY.end.....]')
            self.format_log('done', 'end')
示例#5
0
    def RB_KAFKA_NOTIFY(self):  #9
        self.format_log('kafka发送消息给平台', 'start')
        self.G_DEBUG_LOG.info('[BASE.RB_KAFKA_NOTIFY.start.....]')

        start_time = time.time()
        params = {}
        params["messageKey"] = self.G_ACTION
        params['platform'] = self.G_PLATFORM
        params['messageTime'] = str(int(start_time))
        params['messageId'] = self.G_TASK_ID + '_' + params[
            "messageKey"] + '_' + self.G_JOB_ID

        self.G_KAFKA_MESSAGE_BODY_DICT['zone'] = self.G_ZONE
        self.G_KAFKA_MESSAGE_BODY_DICT['nodeName'] = self.G_NODE_ID
        self.G_KAFKA_MESSAGE_BODY_DICT['jobId'] = self.G_JOB_ID
        self.G_KAFKA_MESSAGE_BODY_DICT['taskId'] = self.G_TASK_ID
        self.G_KAFKA_MESSAGE_BODY_DICT['renderType'] = self.G_RENDER_CORE_TYPE
        #self.G_KAFKA_MESSAGE_BODY_DICT['startTime']=self.G_START_TIME
        #self.G_KAFKA_MESSAGE_BODY_DICT['smallPic']=self.G_SMALL_PIC
        #self.G_KAFKA_MESSAGE_BODY_DICT['endTime']=self.G_END_TIME
        params['messageBody'] = self.G_KAFKA_MESSAGE_BODY_DICT

        self.G_DEBUG_LOG.info('params=' + str(params))

        # write kafka message json file(e.g. C:\work\render\10002736\1849754-10002736-frame0001.json)
        kafka_message_filename = self.G_USER_ID + '-' + self.G_TASK_ID + '-' + self.G_JOB_NAME + '.json'
        kafka_message_json = os.path.join(self.G_WORK_RENDER_TASK,
                                          kafka_message_filename)
        kafka_message_json_str = json.dumps(params, ensure_ascii=False)
        CLASS_COMMON_UTIL.write_file(kafka_message_json_str,
                                     kafka_message_json)
        CLASS_COMMON_UTIL.python_copy(kafka_message_json, self.G_CONFIG_PATH)

        try:
            kafka_result = CLASS_KAFKA.produce(params, self.G_KAFKA_SERVER,
                                               self.G_KAFKA_TOPIC)
            self.G_DEBUG_LOG.info('kafka_result=' + str(kafka_result))
        except:
            CLASS_COMMON_UTIL.error_exit_log(self.G_DEBUG_LOG,
                                             'Send Kafka Message Failed',
                                             is_exit=False)

        self.G_DEBUG_LOG.info('[BASE.RB_KAFKA_NOTIFY.end.....]')
        self.format_log('done', 'end')