def __convert_image_stitching(self, total_image, t_format): out_put = ct.com().get_tmp_path() + "/image_stitching" + t_format convert_path = t_cgtw_path + "/convert.exe" if os.path.exists(convert_path) == False: return self.ct_false(u"( " + convert_path + u" ) 文件不存在") cmd = '"' + convert_path + '" ' + total_image + " -gravity south +append " + '"' + out_put + '"' ct.com().exec_cmd(cmd) if os.path.exists(out_put) == False or os.path.getsize(out_put) <= 0: return False else: return out_put
def common_move(self, a_current_path, a_sou_list, a_is_in_history_add_datetime, a_is_in_history_add_version, a_is_force_cover_no_message=False): #current_path指的是当前文件框的路径 des_path = "" new_des_list = [] new_sou_list = [] if len(a_sou_list) > 0: for sou_file in a_sou_list: #判断文件是否存在 if not os.path.exists(sou_file): continue new_sou_list.append(sou_file) temp_sou_file = sou_file if ct.com().get_os() == "mac" and os.path.isdir(sou_file): temp_sou_file = unicode(sou_file).rstrip("\\").rstrip("/") if a_is_in_history_add_datetime == "y": des_path = a_current_path + "/history/" + ct.com().now( '%Y-%m-%d-%H-%M-%S') + "/" + os.path.basename( temp_sou_file) else: des_path = a_current_path + "/history/" + os.path.basename( temp_sou_file) temp_des_file = des_path if a_is_in_history_add_version == "y": temp_des_file = ct_lib.com().auto_add_version(des_path) if ct.com().get_os() == "mac" and os.path.isdir(sou_file): temp_des_file = temp_des_file + "/" new_des_list.append(temp_des_file) if len(new_sou_list) > 0 and len(new_sou_list) == len( new_des_list): self.copy = ct_ui.copy_widget(new_sou_list, new_des_list, None, False, True, a_is_force_cover_no_message) if self.copy.exec_() == QDialog.Accepted: return True else: return False return True
def filebox_bulk_download_from_online(): try: t_tw = tw() t_module = t_tw.sys().get_sys_module() t_module_type = t_tw.sys().get_sys_module_type() t_db = t_tw.sys().get_sys_database() task_id_list = t_tw.sys().get_sys_id() t_filebox_id = t_tw.sys()._get_sys_key("filebox_id") t_is_all = t_tw.sys()._get_sys_key("is_all") res = t_tw.con._send( "c_media_file", "get_filebox_bulk_download_data", { "db": t_db, "module": t_module, "module_type": t_module_type, "os": ct.com().get_os(), "is_all": t_is_all, "filebox_id": t_filebox_id, "task_id_array": task_id_list }) for dic in res: t_current_folder_id = dic["current_folder_id"] t_data_list = dic["data_list"] t_filebox_data = dic["filebox_data"] t_des_dir = dic["des_dir"] if isinstance(t_data_list, list): for t_dict_data in t_data_list: if isinstance(t_dict_data, dict) and t_dict_data.has_key( "id") and t_dict_data.has_key( "name") and t_dict_data.has_key("is_folder"): #print t_dict_data["name"]+u' --> send to queue' t_task_data = { 'name': t_dict_data["name"], 'task': [{ "action": "download", "is_contine": True, "data_list": [t_dict_data], "db": t_db, "des_dir": t_des_dir, "filebox_data": t_filebox_data, "current_folder_id": t_current_folder_id }] } t_tw.local_con._send("queue_widget", "add_task", {"task_data": t_task_data}, "send") except Exception, e: ct.log().add(traceback.format_exc(), __file__) message().error(u"(bulk_download_from_online)下载失败:\n" + e.message)
def download_image(a_fun, a_http_ip, a_cgtw_path, a_token, a_db, a_module, a_module_type, a_id_list, a_field_sign, a_is_small=True, a_local_path=""): if not isinstance(a_http_ip, (str, unicode)) or not isinstance(a_cgtw_path, (str, unicode)) or not isinstance(a_token, (str, unicode)) or \ not isinstance(a_db, (str, unicode)) or not isinstance(a_module, (str, unicode)) or not isinstance(a_module_type, (str, unicode)) or \ not isinstance(a_id_list, list) or not isinstance(a_field_sign, (str, unicode)) or not isinstance(a_is_small, bool) or not isinstance(a_local_path, (str, unicode)): raise Exception("_module.download_image argv error, must be( str,str,str,list,str,bool,str)") t_os=_lib.get_os() if a_cgtw_path not in sys.path: sys.path.append(a_cgtw_path) import ct t_localpath=a_local_path if t_localpath.strip()=="": t_localpath=ct.com().get_tmp_path() if not os.path.exists(t_localpath): try: os.mkdir(t_localpath) except Exception, e: raise Exception(e)
def filebox_bulk_upload_to_online(): try: t_tw = tw() t_module = t_tw.sys().get_sys_module() t_module_type = t_tw.sys().get_sys_module_type() t_db = t_tw.sys().get_sys_database() task_id_list = t_tw.sys().get_sys_id() t_filebox_id = t_tw.sys()._get_sys_key("filebox_id") t_is_all = t_tw.sys()._get_sys_key("is_all") res = t_tw.con._send( "c_media_file", "get_filebox_bulk_upload_data", { "db": t_db, "module": t_module, "module_type": t_module_type, "os": ct.com().get_os(), "filebox_id": t_filebox_id, "task_id_array": task_id_list }) if isinstance(res, dict) and res.has_key("is_submit") and res.has_key( "upload_to_server_action") and res.has_key( "show_type") and res.has_key("filebox_data_list"): t_action = 'upload' t_is_submit = unicode(res["is_submit"]).lower() t_show_type = unicode(res["show_type"]).lower() t_filebox_data_list = res["filebox_data_list"] temp_act = res["upload_to_server_action"] if unicode("," + temp_act + ",").find(",convert_before_upload,") != -1: t_action = "convert_movie_to_mp4" if unicode("," + temp_act + ",").find(",convert_image_before_upload,") != -1: t_action = "convert_image_to_image" if unicode("," + temp_act + ",").find(",sequence_output_video,") != -1: t_action = "convert_seq_image_to_mov" #开始处理 if isinstance(t_filebox_data_list, list): for t_dict_data in t_filebox_data_list: if isinstance( t_dict_data, dict ) and t_dict_data.has_key("path") and t_dict_data.has_key( "server" ) and t_dict_data.has_key("rule") and t_dict_data.has_key( "task_id") and t_dict_data.has_key("title"): t_rule_list = t_dict_data["rule"] t_path = t_dict_data["path"] t_server = t_dict_data["server"] t_task_id = t_dict_data["task_id"] t_title = t_dict_data["title"] t_version_id = ct.com().uuid() #随机生成的ID re_list = change_to_regexp_list(t_rule_list) #遍历本地文件排除histroy if os.path.exists(t_path): t_list = ct.file().get_path_list(t_path, re_list) t_new_list = [] for i in t_list: if os.path.isdir(unicode(i)) and unicode( os.path.basename( i)).lower() == "history": continue i = unicode(i).replace("\\", "/") t_new_list.append(i) if len(t_new_list) == 0: continue if isinstance(t_is_all, (str, unicode)) and unicode( t_is_all).strip().lower() != "y": t_new_list = __sorted(t_new_list, True) t_new_list = [t_new_list[0]] t_first = False for i in t_new_list: t_upload_list = [{ "sou": i, "des": unicode(i).replace(t_server, "/") }] if unicode(t_is_submit).strip().lower() == "y": if t_first == False: #上传verison if upload_version({ "db": t_db, "module": t_module, "module_type": t_module_type, "task_id": t_task_id, "des_file_list": t_list, "title": t_title, "version_id": t_version_id, "server": t_server, "tw": t_tw }) != True: message().error(u"创建Version失败") return #修改task表中的version_ID res = t_tw.con._send( "c_orm", "update_version_id", { "id": t_task_id, "db": t_db, "module": t_module, "module_type": t_module_type, "version_id": t_version_id }) if res != True: return t_first = True file_name = os.path.basename( t_upload_list[0]["sou"]) t_dic = { 'name': file_name, 'task': [{ "action": t_action, "is_contine": True, "data_list": t_upload_list, "db": t_db, "module": t_module, "module_type": t_module_type, "task_id": t_task_id, "version_id": t_version_id }] } #print t_dic["name"] +u' --> send to queue' t_tw.local_con._send("queue_widget", "add_task", {"task_data": t_dic}, "send") except Exception, e: ct.log().add(traceback.format_exc(), __file__) message().error(u"(bulk_upload_to_online)上传失败:\n" + e.message)
def image_stitching(self, a_argv, a_tw): # 仕煌 ''' 多张图片拼接成新图片,#图片拼接,并生成一个新的图片,不复制原先的图片 0. action : image_stitching (必填) ''' t_argv = a_argv t_sou_list = t_argv.get_sys_file() # 取固定的系统数据 t_folder = t_argv.get_sys_folder() # 取文件框对应的目录. if t_folder == False or str(t_folder) == "": return self.ct_false(u"取目录失败") if os.path.exists(t_folder) == False: return self.ct_false(u"目录(" + t_folder + u")未创建") if isinstance(t_sou_list, list) == False: return self.ct_false(u"提交文件类型错误") if len(t_sou_list) <= 0: return self.ct_false(u"没有找到提交文件") try: des_file_path = "" total = "" t_uuid_file_list = [] t_sou_list.sort() for i in t_sou_list: if des_file_path == "": des_file_path = t_folder + "/" + os.path.basename(i) if ct.com().exist_chinese(i): # 是否存在中文命名 temp_file = ct.com().get_tmp_path() + "/" + str( ct.com().uuid()) + "." + os.path.splitext(i)[1] if os.path.exists(temp_file): os.remove(temp_file) #===============骁颖==2018.06.15===================== #shutil.copyfile(i, temp_file) ct.file().copy_file(i, temp_file) #===============骁颖==2018.06.15===================== t_uuid_file_list.append(temp_file) total = total + ' ' + '"' + temp_file + '"' else: total = total + ' ' + '"' + i + '"' res = self.__convert_image_stitching( total, os.path.splitext(des_file_path)[1]) if res == False: return self.ct_false(u"调用转换命令,拼接失败") else: if os.path.exists(des_file_path): os.remove(des_file_path) #===============骁颖==2018.06.15===================== #shutil.copyfile(res, des_file_path) ct.file().copy_file(res, des_file_path) #===============骁颖==2018.06.15===================== for i in t_uuid_file_list: os.remove(i) # 停止后续的插件/或者动作 return self.ct_stop_next() except Exception, e: return self.ct_false(u"拼接图片失败")
def drag_mov_get_thumbnail(self, a_argv, a_tw): """ Author: 黄骁颖 Purpose: 拖入mov生成缩略图并检查帧数 Created: 2018-07-03 文件筐插件,拖入mov/右键mov(可以选择/拖入文件夹): 0. action: drag_mov_get_thumbnail (必填) 1: is_get_thumbnail, 是否更新缩略图 ex: Y/N key可以不填写 2: is_update_frame, 是否更新帧数 ex: Y/N key可以不填写 3: is_check_frame, 是否检查帧数 ex: Y/N key可以不填写 4: is_get_folder, 是否查询目录里的文件 ex: Y/N key可以不填写 5: image_sign, 生成缩略图字段标识 ex: shot.image key可以不填写 6: des_file_sign, 拷贝到目标目录标识 ex: maya_work key可以不填写 7: frame_rate, 帧率 ex:24 key可以不填写 8: width 宽 key可以不填写 9: height 高 key可以不填写 """ try: t_tw = a_tw t_argv = a_argv k_is_get_thumanil = t_argv.get_argv_key("is_get_thumbnail") k_is_update_frame = t_argv.get_argv_key("is_update_frame") k_is_check_frame = t_argv.get_argv_key("is_check_frame") k_is_get_folder = t_argv.get_argv_key("is_get_folder") k_image_sign = t_argv.get_argv_key("image_sign") k_des_file_sign = t_argv.get_argv_key("des_file_sign") k_frame_rate = t_argv.get_argv_key("frame_rate") k_width = t_argv.get_argv_key("width") k_height = t_argv.get_argv_key("height") t_database = t_argv.get_sys_database() t_id_list = t_argv.get_sys_id() t_module = t_argv.get_sys_module() t_module_type = t_argv.get_sys_module_type() t_sou_list = t_argv.get_sys_file() # 取固定的系统数据 INFO_FIELD_SIGN = 1 # 信息模块标识 TASK_FIELD_SIGN = 2 # 制作模块标识 #t_fail_list = [] # 获取文件list处理 if k_is_get_folder != False and unicode( k_is_get_folder).strip().lower() == "y": t_new_list = [] for i in t_sou_list: if os.path.isdir(i): t_new_list = t_new_list + ct.file().get_path_list(i) else: t_new_list.append(i) else: t_new_list = t_sou_list for i in t_new_list: if os.path.isfile(i): t_fileUrl = i.replace("\\", "/") # 获取视频信息及缩略图------------------------------------ try: t_avi_info = ct.mov().get_avi_info(i) t_fate = t_avi_info["FrameRate"] t_frame = t_avi_info["FrameCount"] t_avi_thumanil = ct.com().get_tmp_path( ) + "/" + ct.com().uuid() + ".png" ct.mov().get_mov_thumbnail( i, t_avi_thumanil.replace("\\", "/")) t_thumanil = t_avi_thumanil.replace("\\", "/") t_avi_info_dict = t_avi_info except Exception, e: return self.ct_false(t_fileUrl + u": 获取视频信息失败") #t_fail_list.append(t_fileUrl + u": 获取视频信息失败") #continue # 检查宽高----------------------------------------------- try: if str(k_width).strip() != "" and k_width != False: if t_avi_info_dict != False and t_avi_info_dict.has_key( "Width"): if int(k_width) != int( t_avi_info_dict["Width"]): return self.ct_false( t_fileUrl + u": 宽度不正确:-----系统宽度-----mov宽度\n" + u"-----" + str(int(k_width)) + u"-----" + str(int(t_avi_info_dict["Width"]))) #t_fail_list.append(t_fileUrl + u": 宽度不正确:-----系统宽度-----mov宽度\n" + u"-----" + str(int(k_width)) + u"-----" + str(int(t_avi_info_dict["Width"]))) #continue else: return self.ct_false(t_fileUrl + u": 读取mov分辨率出错") #t_fail_list.append(t_fileUrl + u": 读取mov分辨率出错") #continue if str(k_height).strip() != "" and k_height != False: if t_avi_info_dict != False and t_avi_info_dict.has_key( "Heigh"): if int(k_height) != int( t_avi_info_dict["Heigh"]): return self.ct_false( t_fileUrl + u": 高度不正确:-----系统高度-----mov高度\n" + u"-----" + str(int(k_height)) + u"-----" + str(int(t_avi_info_dict["Heigh"]))) #t_fail_list.append(t_fileUrl + u": 高度不正确:-----系统高度-----mov高度\n" + u"-----" + str(int(k_height)) + u"-----" + str(int(t_avi_info_dict["Heigh"]))) #continue else: return self.ct_false(t_fileUrl + u": 读取mov分辨率出错") #t_fail_list.append(t_fileUrl + u": 读取mov分辨率出错") #continue except Exception, e: return self.ct_false(t_fileUrl + u": 检查分辨率发生未知错误!") #t_fail_list.append(t_fileUrl + u": 检查分辨率发生未知错误!") #continue # 检查帧率---------------------------------------------- try: if str(k_frame_rate).strip( ) != "" and k_frame_rate != False: if int(float(k_frame_rate)) != int(float(t_fate)): return self.ct_false( t_fileUrl + u": 帧率不正确:-----系统帧率-----mov帧率\n" + u"-----" + str(int(float(k_frame_rate))) + u"-----" + str(int(float(t_fate)))) #t_fail_list.append(t_fileUrl + u": 帧率不正确:-----系统帧率-----mov帧率\n" + u"-----" + str( #int(float(k_frame_rate))) + u"-----" + str(int(float(t_fate)))) #continue except Exception, e: return self.ct_false(t_fileUrl + u": 检查帧率发生未知错误!") #t_fail_list.append(t_fileUrl + u": 检查帧率发生未知错误!") #continue # 检查帧数---------------------------------------------- if str(k_is_check_frame).strip().lower() == "y": try: t_info_id = t_tw.task_module( t_database, t_module, t_id_list).get([t_module + ".id" ])[0][t_module + ".id"] t_frmaes = t_tw.info_module( t_database, "shot", [t_info_id]).get(["shot.frame" ])[0]["shot.frame"] if t_frmaes == "None" or t_frmaes == False or t_frmaes == "" or t_frmaes == None: t_frmaes = 0 if int(t_frame) != int(t_frmaes): return self.ct_false( t_fileUrl + u": 帧数不正确:-----系统帧数-----mov帧数\n" + u"-----" + str(int(t_frmaes)) + u"-----" + str(int(t_frame))) #t_fail_list.append(t_fileUrl + u": 帧数不正确:-----系统帧数-----mov帧数\n" + u"-----" + str( #int(t_frmaes)) + u"-----" + str(int(t_frame))) #continue except Exception, e: return self.ct_false(t_fileUrl + u": 检查/更新帧数,发生未知错误!")