def shouldUpdate(): for file in glob.glob("version.txt"): with open(file) as f: c = f.readlines() origin_version = c[0].replace("\n", "") origin_branch = c[1].replace("\n", "") r = requests.get( f"https://raw.githubusercontent.com/{repository}/{origin_branch}/version.txt" ) if (r.status_code == 404): return False, 0, 0, 0 remote_text = r.text.split("\n") remote_version = remote_text[0] if (remote_version == origin_version): return False, 0, 0, 0 shouldUpdate = settings["force_cheat_update"] or (locales.advInput( "NEW_VERSION_AVAILABLE_INPUT", globals={ "origin_version": origin_version, "remote_version": remote_version }) in YES) if (not shouldUpdate): return False, 0, 0, 0 return True, origin_version, remote_version, origin_branch return False, 0, 0, 0
def runContinueUpdateLoop(generated_folder_path): update.continue_actions(generated_folder_path) if (generated_folder_path is not None and locales.advInput("DELETE_FOLDER_AFTER_BUILDING_INPUT") in YES): update.delete_folder(generated_folder_path) compile_tools.compile() utils.askStartCheat()
def download_repo(origin_branch): locales.advPrint("DOWNLOADING_NEW_VERSION") new_path = f"{settings.repository_name}-{origin_branch}" if (os.path.exists(new_path)): if (locales.advInput("FOLDER_ALREADY_EXIST_INPUT", {"new_path": new_path}) in YES): utils.rmtree(new_path) locales.advPrint("FOLDER_DELETED") utils.downloadFileAndExtract( f"https://github.com/{settings['github_repo']}/archive/{origin_branch}.zip", f"{origin_branch}.zip") locales.advPrint("DOWNLOADING_FINISHED") return new_path
def compile(): locales.advPrint("BUILDING") subprocess.check_call(["gradlew.bat", "RatPoison"]) deleteLibsFolder() utils.killJDKs() bat_file = utils.getBatName() for path in utils.searchFile("java.exe"): if (utils.verifyPath(str(path))): java_exe = str(path) with open(bat_file, "r") as rFile: prevLines = rFile.readlines() prevLines[4] = prevLines[4].replace("java", f"\"{java_exe}\"", 1) with open(bat_file, "w") as wFile: wFile.writelines(prevLines) break if (locales.advInput("RANDOMIZE_FILE_NAMES_INPUT") in locales.YES): randomize_file_names() replace_bat_pathes()
def askStartCheat(): if (locales.advInput("START_CHEAT_INPUT") in locales.YES): startCheat()