def build(): config = tools.get_scriptconfig() configdir = CURPATH + "/publish/config" tempdir = CURPATH + "/temp" compackdir = CURPATH + "/" + config["path"][ "packs"] + "/installed/completes" pubpackdir = CURPATH + "/" + config["path"]["packs"] + "/publish" if not os.path.exists(compackdir): raise Exception("未找到安装游戏资源:" + compackdir) if os.path.exists(pubpackdir): shutil.rmtree(pubpackdir) os.makedirs(pubpackdir) if not os.path.exists(configdir): os.makedirs(configdir) if not os.path.exists(tempdir): os.makedirs(tempdir) playpacks = [] resversion = {} # 搜索剧本依赖与所属包 localconfig = config["publish"]["localconfig"] localplays = {} localconfig["plays"] = localplays allplays = tools.read_json(CURPATH + "/" + config["path"]["game"] + "/plays.json") def addplay(pname): if pname in allplays: play = allplays[pname] pack = play["pack"] if pname not in localplays: localplays[pname] = play if pack not in playpacks: playpacks.append(pack) if "prefix" in play: addplay(play["prefix"]) for pname in config["publish"]["preplays"]: addplay(pname) tools.write_json(localconfig, tempdir + "/" + LOCALCONFIG, config['debug']) cryptoConfig.do_crypto("E", tempdir + "/" + LOCALCONFIG, configdir + "/" + LOCALCONFIG) # 生成pack目录 allpacks = config["publish"]["basepacks"] + playpacks for pack in allpacks: shutil.copyfile(compackdir + "/" + pack + ".pack", pubpackdir + "/" + pack + ".pack") packvers = 0 with open(compackdir + "/" + pack + ".pack", "rb") as f: packvers = tools.getLongValue(f.read(4)) resversion[pack] = packvers # 生成资源版本文件 with open(compackdir + "/boot.pack", "rb") as f: packvers = tools.getLongValue(f.read(4)) resversion['boot'] = packvers tools.write_json(resversion, configdir + "/" + RESVERSION, config['debug'])
def saveCpp(self): indexbranchs = [] index = 0 for aes in self.aeskeys: keybranchs = [] ivbranchs = [] for i in range(16): keybranchs.append(KEYBRANCH_TEMPLATE % (i,"\\x"+aes["key"][i*2:i*2+2])) ivbranchs.append(IVBRANCH_TEMPLATE % (i,"\\x"+aes["iv"][i*2:i*2+2])) indexbranchs.append(INDEXBRANCH_TEMPLATE % (index,"\n".join(keybranchs),"\n".join(ivbranchs))) index += 1 cppfile = tools.get_scriptconfig()["path"]["aeskeyscpp"] with open(cppfile,"w") as f: f.write(CPP_TEMPLATE % ("\n".join(indexbranchs),self.confaes))
def updateModels(): config = tools.get_scriptconfig() dopacks = config['update']['dopacks'] # 更新节点 def updateNode(nodename): print(">>>>>>>>>>>>>>>>>>>[%s]模型>>>>>>>>>>>>>>>>>>>" % nodename) try: ModelUpdater(config,nodename).update() print("<<<<<<<<<<<<<<<<<<<更新完成<<<<<<<<<<<<<<<<<<<\n") except Exception as e: print(e) print("<<<<<<<<<<<<<<<<<<<更新失败!!!<<<<<<<<<<<<<<<<<<<\n") # 遍历所有包 for nodename in os.listdir(CURPATH + "/" + config["path"]["game"]): if os.path.isdir(CURPATH + "/" + config["path"]["game"] + "/" + nodename) and tools.wildcard_matchs(dopacks,nodename): updateNode(nodename)
# Find VS path msbuild_path = None for reg_flag in reg_flag_list: try: vs = winreg.OpenKey( winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\MSBuild\ToolsVersions\%s" % vs_ver, 0, winreg.KEY_READ | reg_flag) msbuild_path, type = winreg.QueryValueEx( vs, 'MSBuildToolsPath') except: continue if msbuild_path is not None: msbuild_path = os.path.join(msbuild_path, "MSBuild.exe") if os.path.exists(msbuild_path): break else: msbuild_path = None return msbuild_path if __name__ == "__main__": try: WindowsPublisher(tools.get_scriptconfig()).publish() print("Windows版本发布完成") except Exception as e: print(e) os.system("pause")
def get_configaes(): config = tools.get_scriptconfig() return config["aes"]["keys"][config["aes"]["confindex"]]
self.writeLog("Upload Split File %s/%s/%s %s\n" % (nodename,patchname,file,"SUCCESS" if upresult else "FAILURE")) self.packsconf[nodename]["patchs"][patchname] = { "path" : rmpatchdir[len(self.syncconf["dataroot"]):], "format" : ZLIBFORMAT, "count" : filecount, "size" : totalsize } tools.write_json(self.packsconf[nodename]["patchs"][patchname], self.temppath + "/patch.config.json") upresult = self.reupload_file(self.temppath + "/patch.config.json",rmpatchtmp + "/config.json",True) self.ftp.rename(rmpatchtmp,rmpatchdir) else: downresult = self.redownload_file(rmpatchdir + "/config.json",self.temppath + "/patch.config.json") if not downresult: raise Exception("read fail : " + rmpatchdir + "/config.json") self.packsconf[nodename]["patchs"][patchname] = tools.read_json(self.temppath + "/patch.config.json") self.writeLog("Sync Patch %s End\n" % patch) self.writeLog("Sync All Patch End\n") if __name__=="__main__": try: ServerSynchro(tools.get_scriptconfig()).sync() print("服务器同步完成") except Exception as e: print(e) os.system("pause")
patchname = tools.getVersionName( oldvers) + "_" + tools.getVersionName(verscode) + ".patch" temppatch = self.temppath + "/" + patchname HDiffPatch.create_diff(filepath, compfile, temppatch) if os.path.getsize(temppatch) < os.path.getsize(filepath): npatchpath = self.patchspath + "/" + nodename if not os.path.isdir(npatchpath): os.makedirs(npatchpath) shutil.copyfile(temppatch, npatchpath + "/" + patchname) self.writeLog("Create Patch File : %s\n" % patchname) shutil.copyfile(filepath, compfile) if nodename.lower() == "boot": shutil.copyfile(filepath, self.runpath + "/" + filename) else: shutil.copyfile(filepath, self.runpacks + "/" + filename) self.writeLog("Update To Version : %s\n" % tools.getVersionName(verscode)) if __name__ == "__main__": try: ResourceInstaller(tools.get_scriptconfig()).install() print("资源安装完成") except Exception as e: print(e) os.system("pause")
def saveConfig(self): config = tools.get_scriptconfig() config["aes"]["confindex"] = self.confaes config["aes"]["keys"] = self.aeskeys tools.save_scriptconfig(config)
self.writeLog("gradle commands : %s\n" % (" ".join(commands))) lastwd = os.getcwd() os.chdir(self.andprojpath) subprocess.call(commands) os.chdir(lastwd) return buildapkpath if __name__ == "__main__": try: options = {} ''' 命令分割 , 提升版本 [vers]+[1/2/3] 默认 1 (1 修订版本, 2 次本版, 3 主版本) ''' pubcmdsstr = input("输入发布命令:").strip() if pubcmdsstr != "": pubcmdstr = pubcmdsstr.split(",") for pubcmd in pubcmdstr: if "+" in pubcmd: optstr = pubcmd.split("+") if len(optstr) == 2 and optstr[0].lower()=="vers": options["addversion"] = int(optstr[1].strip()) AndroidPublisher(tools.get_scriptconfig(),options).publish() print("安卓版本发布完成") except Exception as e: print(e) os.system("pause")
if __name__ == "__main__": try: packs = {} versadds = {} ''' 命令分割 , 使能打包 [nodename]=[true/false] 默认 true 提升版本 [nodename]+[1/2/3] 默认 1 (1 修订版本, 2 次本版, 3 主版本) ''' packcmdsstr = input("输入打包命令:").strip() if packcmdsstr != "": packcmdstr = packcmdsstr.split(",") for packcmd in packcmdstr: if "+" in packcmd: optstr = packcmd.split("+") if len(optstr) == 2: versadds[optstr[0].strip()] = int(optstr[1].strip()) elif "=" in packcmd: optstr = packcmd.split("=") if len(optstr) == 2: packs[optstr[0].strip()] = optstr[1].strip().upper() != "FALSE" ResourcePacker(tools.get_scriptconfig(),{ "packs":packs, "versadds":versadds }).pack() print("资源打包完成") except Exception as e: print(traceback.format_exc()) os.system("pause")