def edit_store_resource(exlPath, e=1): path = r"C:\Users\ws\Desktop\20181208" #当e的值不为1时,代表不需要重新上传资源 m = MyExcelUtil(exlPath) listDir = list_dir(path) for d in listDir: zip_dir(d) dir = path + "\\" time = 0 for j in range(0, 6): for i in range(1, m.get_row_num(j)): if m.get_rowCol_data(i, 8, j).upper() == "Y": zipDir = dir + m.get_rowCol_data( i, 7, j) + "\\" + m.get_rowCol_data(i, 2, j) + ".zip" print zipDir if os.path.exists(zipDir): # print zipDir if m.get_rowCol_data(i, 7, j).lower() == "title": resource_type = 1 elif m.get_rowCol_data(i, 7, j).lower() == "transition": resource_type = 2 elif m.get_rowCol_data(i, 7, j).lower() == "filter": resource_type = 3 elif m.get_rowCol_data(i, 7, j).lower() == "overlay": resource_type = 4 elif m.get_rowCol_data(i, 7, j).lower() == "audio": resource_type = 6 elif m.get_rowCol_data(i, 7, j).lower() == "element": resource_type = 7 try: if e == 1: resUrl = reqApi.post_files(zipDir, 2) print resUrl else: resUrl = "" print "资源不用上传" resText = reqApi.post_ResourceEdit( m.get_rowCol_data(i, 6, j), resUrl, m.get_rowCol_data(i, 3, j), m.get_rowCol_data(i, 4, j), m.get_rowCol_data(i, 5, j), resource_type, "store Edit") if resText.find(u"操作成功") >= 0: time = time + 1 print("操作成功 " + str(time)) MyExcelUtil(exlPath).write_rowNum_data( i, 8, MyExcelUtil.set_style(3), j, "N", "PASS") else: print("操作失败") MyExcelUtil(exlPath).write_data( i, 9, "FAIL", MyExcelUtil.set_style(2), j) except Exception as err: print err MyExcelUtil(exlPath).write_data( i, 9, "FAIL", MyExcelUtil.set_style(2), j)
def up_store_resource(exlPath): dir = r"C:\Users\ws\Desktop\9.0_pack" m = MyExcelUtil(exlPath) listDir = list_dir(dir) for d in listDir: zip_dir(d) time = 0 for j in range(0, 6): for i in range(1, m.get_row_num(j)): if m.get_rowCol_data(i, 8, j).upper() == "Y": zipDir = dir + "\\" + m.get_rowCol_data( i, 7, j) + "\\" + m.get_rowCol_data(i, 2, j) + ".zip" # print zipDir if os.path.exists(zipDir): print zipDir # print type(zipDir) if m.get_rowCol_data(i, 7, j).lower() == "title": resource_type = 1 elif m.get_rowCol_data(i, 7, j).lower() == "transition": resource_type = 2 elif m.get_rowCol_data(i, 7, j).lower() == "filter": resource_type = 3 elif m.get_rowCol_data(i, 7, j).lower() == "overlay": resource_type = 4 elif m.get_rowCol_data(i, 7, j).lower() == "audio": resource_type = 6 elif m.get_rowCol_data(i, 7, j).lower() == "element": resource_type = 7 try: resUrl = reqApi.post_files(zipDir, 2) print resUrl resText = reqApi.post_ResourceAdd( m.get_rowCol_data(i, 6, j), resUrl, m.get_rowCol_data(i, 3, j), m.get_rowCol_data(i, 4, j), m.get_rowCol_data(i, 5, j), resource_type, "store auto") if resText.find(u"操作成功") >= 0: time = time + 1 print("操作成功 " + str(time)) MyExcelUtil(exlPath).write_rowNum_data( i, 8, MyExcelUtil.set_style(3), j, "N", "PASS") elif resText.find(u"唯一标识不能重复") >= 0: print("唯一标识不能重复") MyExcelUtil(exlPath).write_data( i, 9, "FAIL", MyExcelUtil.set_style(2), j) else: print("操作失败") MyExcelUtil(exlPath).write_data( i, 9, "FAIL", MyExcelUtil.set_style(2), j) except Exception as err: print err MyExcelUtil(exlPath).write_data( i, 9, "FAIL", MyExcelUtil.set_style(2), j)
def edit_default_resource(exlPath): dir = r"C:\Users\ws\Desktop\20181208" listDir = list_dir(dir) i = 1 for d in listDir: zip_dir(d) m = MyExcelUtil(exlPath) time = 0 for j in range(0, 7): for i in range(1, m.get_row_num(j)): if m.get_rowCol_data(i, 6, j).upper() == "Y": zipDir = dir + "\\" + m.get_rowCol_data( i, 2, j) + "\\" + m.get_rowCol_data(i, 4, j) + ".zip" # print zipDir if os.path.exists(zipDir): print zipDir if m.get_rowCol_data(i, 2, j).lower() == "title": resource_type = 1 elif m.get_rowCol_data(i, 2, j).lower() == "transition": resource_type = 2 elif m.get_rowCol_data(i, 2, j).lower() == "filter": resource_type = 3 elif m.get_rowCol_data(i, 2, j).lower() == "overlay": resource_type = 4 elif m.get_rowCol_data(i, 2, j).lower() == "splitscreen": resource_type = 5 elif m.get_rowCol_data(i, 2, j).lower() == "audio": resource_type = 6 elif m.get_rowCol_data(i, 2, j).lower() == "element": resource_type = 7 try: resUrl = reqApi.post_files(zipDir, 2) print resUrl resText = reqApi.post_ResourceEdit( m.get_rowCol_data(i, 8, j), resUrl, m.get_rowCol_data(i, 5, j), m.get_rowCol_data(i, 1, j), m.get_rowCol_data(i, 0, j), resource_type, "default Edit") if resText.find(u"操作成功") >= 0: time = time + 1 print("操作成功 " + str(time)) MyExcelUtil(exlPath).write_rowNum_data( i, 6, MyExcelUtil.set_style(3), j, "N", "PASS") else: print("操作失败") MyExcelUtil(exlPath).write_data( i, 7, "FAIL", MyExcelUtil.set_style(2), j) except Exception as err: print err MyExcelUtil(exlPath).write_data( i, 7, "FAIL", MyExcelUtil.set_style(2), j)
def find_id(exlPath): m = MyExcelUtil(exlPath) mydb = MysqldbHelper(host='10.10.19.117', port=3306, user='******', password='******', db='filmora_es_admin') for j in range(4, 6): name = m.get_sheet_names() for i in range(1, m.get_row_num(j)): d = m.get_rowCol_data(i, 1, j) if name[j] == "MUSIC": value = 'sound_' + replace_space2(d).lower() elif name[j] == "TEXT": value = 'text_' + replace_space2(d).lower() elif name[j] == "TRANSITIONS": value = 'trans_' + replace_space2(d).lower() elif name[j] == "FILTERS": value = 'effect_' + replace_space2(d).lower() elif name[j] == "OVERLAYS": value = 'overlay_' + replace_space2(d).lower() elif name[j] == "ELEMENTS": value = 'element_' + replace_space2(d).lower() elif name[j] == "SPLIT": value = 'split_' + replace_space2(d).lower() if m.get_rowCol_data(i, 8, j).upper() == "Y": print value result = mydb.executeSqlOne( 'SELECT id,catdir from wx_resource_category where child = 0 and catdir = \"{}\"'.format(value)) if result is not None: print result["id"] MyExcelUtil(exlPath).write_data(i, 5, result["id"], MyExcelUtil.set_style(8), j)
def up_pack9(exlPath, type=0): """ 打包pack :param exlPath: """ m = MyExcelUtil(exlPath) pack_name = [] for j in range(0, 6): for i in range(1, m.get_row_num(j)): # print m.get_rowCol_data(i, 6, j) # if m.get_rowCol_data(i, 6, j).upper() == "Y": data = m.get_rowCol_data(i, 4, j) pack_name.append(data) pack_name = list(set(pack_name)) print pack_name time = 0 for name in pack_name: resource_name = [] for j in range(0, 6): for i in range(1, m.get_row_num(j)): if m.get_rowCol_data(i, 6, j).upper() == "Y" and m.get_rowCol_data(i, 4, j) == name: resource_name.append(m.get_rowCol_data(i, 3, j)) MyExcelUtil(exlPath).write_rowNum_data(i, 6, MyExcelUtil.set_style(3), j, "N", "PASS") # print resource_name # jp = convert_jp(name) jp = "" print(name, "", replace_space(name), resource_name)
def write_video(path, excelPath, cname): root = get_doc_root(path) Name = root.xpath("//FormatInfo/Name/text()") # print Name for index, name in enumerate(Name): # print index, name if name == cname: video = get_video(path, index + 1) audio = get_audio(path, index + 1) j = len(video) + 1 i = 1 for v in video: v_list = v.split(",") if v_list[0] == "Xvid" or v_list[0] == "MP4V": v_list[0] = "MPEG-4" elif v_list[0] == "MJPG": v_list[0] = "MJPEG" elif v_list[0] == "H264": v_list[0] = "H.264" elif v_list[0] == "MP2V": v_list[0] = "MPEG-2" elif v_list[0] == "H263": v_list[0] = "H.263" print v_list MyExcelUtil(excelPath).write_rowNum_data2( i, 3, MyExcelUtil.set_style(8), index, v_list) i = i + 1 for a in audio: a_list = a.split(",") if a_list[0] == "MP2A": a_list[0] = "MPEG-2 audio" elif a_list[0] == "VBIS": a_list[0] = "Vorbis" if a_list[1] == "1": a_list[1] = "Mono" elif a_list[1] == "2": a_list[1] = "Stereo" else: a_list[1] = "5.1 Surround Sound" print a_list MyExcelUtil(excelPath).write_rowNum_data2( j, 7, MyExcelUtil.set_style(8), index, a_list) j = j + 1
def copy_id(exlPath, exlPath2): dict_data = get_condict() for j in range(0, 6): print MyExcelUtil(exlPath2).get_row_num(j) for i in range(1, MyExcelUtil(exlPath2).get_row_num(j)): d = MyExcelUtil(exlPath2).get_rowCol_data(i, 10, j) print d for key, value in dict_data.items(): if (d == key): MyExcelUtil(exlPath2).write_data(i, 11, value, MyExcelUtil.set_style(2), j) continue
def up_set9(exlPath, type=0): """ 打包set :param exlPath: """ mydb = MysqldbHelper(host='192.168.11.43', port=3306, user='******', password='******', db='store') m = MyExcelUtil(exlPath) set_dict = {} set_dict2 = {} for i in range(1, m.get_row_num(6)): if m.get_rowCol_data(i, 2, 6).upper() == "Y": setName = m.get_rowCol_data(i, 1, 6) packName = m.get_rowCol_data(i, 0, 6) sql = 'SELECT id from wx_pack9 where slug = \"{}\"'.format( replace_space(setName)) result = mydb.executeSqlOne(sql) if result is None: set_dict[packName] = setName set_dict2.update({setName: []}) print set_dict2 for k, v in set_dict.items(): if set_dict2.has_key(v): set_dict2[v].append(k.lower()) else: set_dict2[v] = [] print set_dict2 time = 0 for s, p in set_dict2.items(): print p resource_name = [] for j in range(0, 6): for i in range(1, m.get_row_num(j)): if m.get_rowCol_data(i, 4, j).lower() in p: resource_name.append(m.get_rowCol_data(i, 3, j)) MyExcelUtil(exlPath).write_data(i, 5, "PASS", MyExcelUtil.set_style(3), j) # print resource_name print(s, "", replace_space(s), resource_name) try: if len(resource_name) > 0: if type == 0: resText = reqApi.post_Pack9Add(s, "", replace_space(s), resource_name) else: resText = reqApi.post_shenCutPackAdd(s, "", replace_space(s), resource_name) if resText.find(u"操作成功") >= 0: time = time + 1 print("操作成功 " + str(time)) except Exception as err: print err
def edit(n): """ 修改文件,同步修改excel状态,清空文件夹 :param filepath:修改文件的目录 :param exlPath:excel文件的目录 :param n:excel修改的sheet页 """ files = os.listdir(filepath) m = MyExcelUtil(exlPath) print files j = 0 for f in files: for i in range(1, m.get_row_num(n)): # 匹配对应资源包名称 d = m.get_rowCol_data(i, 2, n) if f == d: j = j + 1 print d, j MyExcelUtil(exlPath).write_rowNum_data(i, 8, MyExcelUtil.set_style(2), n, "Y", "")
def up_store_resource(exlPath, j): m = MyExcelUtil(exlPath) listDir = list_dir(r"E:\work\Filmora9\package\packs") n = -1 for d in listDir: i = 1 n = n + 1 childDir = list_dir(d) for dd in childDir: i = i + 1 zipDir = dd + '.zip' if os.path.exists(zipDir): pass else: zip_ya(dd, zipDir) dir = r"E:\work\Filmora9\package\packs\\" time = 0 for i in range(1, m.get_row_num(j)): if m.get_rowCol_data(i, 8, j).upper() == "Y": zipDir = dir + m.get_rowCol_data( i, 7, j) + "\\" + m.get_rowCol_data(i, 6, j) + ".zip" # print zipDir if os.path.exists(zipDir): print zipDir if m.get_rowCol_data(i, 7, j).lower() == "title": resource_type = 1 elif m.get_rowCol_data(i, 7, j).lower() == "transition": resource_type = 2 elif m.get_rowCol_data(i, 7, j).lower() == "filter": resource_type = 3 elif m.get_rowCol_data(i, 7, j).lower() == "overlay": resource_type = 4 elif m.get_rowCol_data(i, 7, j).lower() == "audio": resource_type = 6 elif m.get_rowCol_data(i, 7, j).lower() == "element": resource_type = 7 MyExcelUtil(exlPath).write_rowNum_data( i, 8, MyExcelUtil.set_style(3), j, "N", "PASS")
def up_set9(exlPath): m = MyExcelUtil(exlPath) set_dict = {} set_dict2 = {} for i in range(1, m.get_row_num(6)): if m.get_rowCol_data(i, 2, 6).upper() == "Y": setName = m.get_rowCol_data(i, 1, 6) packName = m.get_rowCol_data(i, 0, 6) set_dict[packName] = setName set_dict2.update({setName: []}) # print set_dict2 for k, v in set_dict.items(): if set_dict2.has_key(v): set_dict2[v].append(k) else: set_dict2[v] = [] # print set_dict2 time = 0 for s, p in set_dict2.items(): print p resource_name = [] for j in range(0, 6): for i in range(1, m.get_row_num(j)): if m.get_rowCol_data(i, 4, j) in p: resource_name.append(m.get_rowCol_data(i, 3, j)) MyExcelUtil(exlPath).write_data(i, 5, "PASS", MyExcelUtil.set_style(3), j) # print resource_name print(s, "", replace_space(s), resource_name) try: if len(resource_name) > 0: resText = reqApi.post_Pack9Add(s, "", replace_space(s), resource_name) if resText.find(u"操作成功") >= 0: time = time + 1 print("操作成功 " + str(time)) except Exception as err: print err
def up_pack9(exlPath): m = MyExcelUtil(exlPath) pack_name = [] for j in range(0, 6): for i in range(1, m.get_row_num(j)): # print m.get_rowCol_data(i, 6, j) if m.get_rowCol_data(i, 5, j).upper() == "Y": data = m.get_rowCol_data(i, 4, j) pack_name.append(data) pack_name = list(set(pack_name)) print pack_name time = 0 for name in pack_name: resource_name = [] for j in range(0, 6): for i in range(1, m.get_row_num(j)): if m.get_rowCol_data(i, 5, j).upper() == "Y" and m.get_rowCol_data( i, 4, j) == name: resource_name.append(m.get_rowCol_data(i, 3, j)) MyExcelUtil(exlPath).write_rowNum_data( i, 5, MyExcelUtil.set_style(3), j, "N", "PASS") # print resource_name # jp = convert_jp(name) jp = "" print(name, "", replace_space(name), resource_name) try: if len(resource_name) > 0: resText = reqApi.post_Pack9Add(name, jp, replace_space(name), resource_name) if resText.find(u"操作成功") >= 0: time = time + 1 print("操作成功 " + str(time)) except Exception as err: print err print("操作失败")
def write_exl(i, num, *data): exlPath = r"C:\Users\ws\Desktop\filmora9.0_pack\pack.xls" MyExcelUtil(exlPath).write_rowNum_data(i, 2, MyExcelUtil.set_style(0), int(num), *data)
def edit_store_resource(exlPath, e=1): """ 编辑商城资源 :param exlPath: :param e: 为1时需要上传资源,其余不需要上传 """ path = r"E:\Filmore\package\Filmaro9.X-FX-Vault\Resource Packs" # 当e的值不为1时,代表不需要重新上传资源 m = MyExcelUtil(exlPath) listDir = list_dir(path) for d in listDir: zip_dir(d) dir = path + "\\" time = 0 for j in range(0, 6): for i in range(1, m.get_row_num(j)): if m.get_rowCol_data(i, 8, j).upper() == "Y": zipDir = dir + m.get_rowCol_data(i, 7, j) + "\\" + m.get_rowCol_data(i, 2, j) + ".zip" print zipDir if os.path.exists(zipDir): # print zipDir if m.get_rowCol_data(i, 7, j).lower() == "title": resource_type = 1 elif m.get_rowCol_data(i, 7, j).lower() == "transition": resource_type = 2 elif m.get_rowCol_data(i, 7, j).lower() == "filter": resource_type = 3 elif m.get_rowCol_data(i, 7, j).lower() == "overlay": resource_type = 4 elif m.get_rowCol_data(i, 7, j).lower() == "audio": resource_type = 6 elif m.get_rowCol_data(i, 7, j).lower() == "element": resource_type = 7 try: if e == 1: if "Filmora" in exlPath: resUrl = reqApi.post_files(zipDir, 2) print resUrl else: resUrl = reqApi.post_shenCut_files(zipDir) print resUrl else: resUrl = "" print "资源不用上传" if "Filmora" in exlPath: resText = reqApi.post_ResourceEdit(m.get_rowCol_data(i, 6, j), resUrl, m.get_rowCol_data(i, 3, j), m.get_rowCol_data(i, 4, j), m.get_rowCol_data(i, 5, j), resource_type, "store Edit") else: import time as t if time > 0: t.sleep(120) resText = reqApi.post_shenCutEdit(m.get_rowCol_data(i, 6, j), resUrl, m.get_rowCol_data(i, 3, j), m.get_rowCol_data(i, 4, j), m.get_rowCol_data(i, 5, j), resource_type, "shencut store Edit") if resText.find(u"操作成功") >= 0: time = time + 1 print("操作成功 " + str(time)) MyExcelUtil(exlPath).write_rowNum_data(i, 8, MyExcelUtil.set_style(3), j, "N", "PASS") else: print("操作失败") MyExcelUtil(exlPath).write_data(i, 9, "FAIL", MyExcelUtil.set_style(2), j) except Exception as err: print err MyExcelUtil(exlPath).write_data(i, 9, "FAIL", MyExcelUtil.set_style(2), j)
def up_store_resource(exlPath): """ 上传商城资源 :param exlPath: """ dir = r"E:\Filmore\package\Filmaro9.X-FX-Vault\Resource Packs" m = MyExcelUtil(exlPath) listDir = list_dir(dir) for d in listDir: zip_dir(d) time = 0 for j in range(0, 6): for i in range(1, m.get_row_num(j)): if m.get_rowCol_data(i, 8, j).upper() == "Y": zipDir = dir + "\\" + m.get_rowCol_data(i, 7, j) + "\\" + m.get_rowCol_data(i, 2, j) + ".zip" print zipDir if os.path.exists(zipDir): # print zipDir # import shutil # zipDir2 = r"C:\Users\ws\Desktop\2\\" + m.get_rowCol_data(i, 3, j) + ".zip" # shutil.copy(zipDir,zipDir2) # print type(zipDir) if m.get_rowCol_data(i, 7, j).lower() == "title": resource_type = 1 elif m.get_rowCol_data(i, 7, j).lower() == "transition": resource_type = 2 elif m.get_rowCol_data(i, 7, j).lower() == "filter": resource_type = 3 elif m.get_rowCol_data(i, 7, j).lower() == "overlay": resource_type = 4 elif m.get_rowCol_data(i, 7, j).lower() == "audio": resource_type = 6 elif m.get_rowCol_data(i, 7, j).lower() == "element": resource_type = 7 try: if "Filmora" in exlPath: resUrl = reqApi.post_files(zipDir, 2) print resUrl resText = reqApi.post_ResourceAdd(m.get_rowCol_data(i, 6, j), resUrl, m.get_rowCol_data(i, 3, j), m.get_rowCol_data(i, 4, j), m.get_rowCol_data(i, 5, j), resource_type, "store auto") else: resUrl = reqApi.post_shenCut_files(zipDir) print resUrl # resUrl = "" resText = reqApi.post_shenCutAdd(m.get_rowCol_data(i, 6, j), resUrl, m.get_rowCol_data(i, 3, j), m.get_rowCol_data(i, 4, j), m.get_rowCol_data(i, 5, j), resource_type, "shenCut store auto") if resText.find(u"操作成功") >= 0: time = time + 1 print("操作成功 " + str(time)) MyExcelUtil(exlPath).write_rowNum_data(i, 8, MyExcelUtil.set_style(3), j, "N", "PASS") elif resText.find(u"唯一标识不能重复") >= 0: print("唯一标识不能重复") MyExcelUtil(exlPath).write_data(i, 9, "FAIL", MyExcelUtil.set_style(2), j) else: print("操作失败") MyExcelUtil(exlPath).write_data(i, 9, "FAIL", MyExcelUtil.set_style(2), j) except Exception as err: print err MyExcelUtil(exlPath).write_data(i, 9, "FAIL", MyExcelUtil.set_style(2), j)
def edit_default_resource(exlPath, type=0): """ 编辑内置资源 :param exlPath: """ dir = r"E:\Filmore\package\Filmaro9.X-FX-Vault\Default" listDir = list_dir(dir) i = 1 for d in listDir: zip_dir(d) m = MyExcelUtil(exlPath) time = 0 for j in range(0, 8): for i in range(1, m.get_row_num(j)): if m.get_rowCol_data(i, 6, j).upper() == "Y": zipDir = dir + "\\" + m.get_rowCol_data(i, 2, j) + "\\" + m.get_rowCol_data(i, 4, j) + ".zip" print zipDir if os.path.exists(zipDir): # print zipDir if m.get_rowCol_data(i, 2, j).lower() == "title": resource_type = 1 elif m.get_rowCol_data(i, 2, j).lower() == "transition": resource_type = 2 elif m.get_rowCol_data(i, 2, j).lower() == "filter": resource_type = 3 elif m.get_rowCol_data(i, 2, j).lower() == "overlay": resource_type = 4 elif m.get_rowCol_data(i, 2, j).lower() == "splitscreen": resource_type = 5 elif m.get_rowCol_data(i, 2, j).lower() == "audio": resource_type = 6 elif m.get_rowCol_data(i, 2, j).lower() == "element": resource_type = 7 elif m.get_rowCol_data(i, 2, j).lower() == "media": resource_type = 8 elif m.get_rowCol_data(i, 2, j).lower() == "sfx": resource_type = 10 try: if type == 0: resUrl = reqApi.post_files(zipDir, 2) print resUrl # resUrl = "" resText = reqApi.post_ResourceEdit(m.get_rowCol_data(i, 8, j), resUrl, m.get_rowCol_data(i, 5, j), m.get_rowCol_data(i, 1, j), m.get_rowCol_data(i, 0, j), resource_type, "default Edit" ) else: # resUrl = reqApi.post_shenCut_files(zipDir) # print resUrl resUrl = "" # print "资源不用上传" resText = reqApi.post_shenCutEdit(m.get_rowCol_data(i, 8, j), resUrl, m.get_rowCol_data(i, 5, j), m.get_rowCol_data(i, 1, j), m.get_rowCol_data(i, 0, j), resource_type, "shenCut Edit" ) if resText.find(u"操作成功") >= 0: time = time + 1 print("操作成功 " + str(time)) MyExcelUtil(exlPath).write_rowNum_data(i, 6, MyExcelUtil.set_style(3), j, "N", "PASS") import time as t t.sleep(200) else: print("操作失败") MyExcelUtil(exlPath).write_data(i, 7, "FAIL", MyExcelUtil.set_style(2), j) except Exception as err: print err MyExcelUtil(exlPath).write_data(i, 7, "FAIL", MyExcelUtil.set_style(2), j)