def compile(): if settings["download_missing_files"]: version = repository.Version.get_version_file() repo.compare_tree(version.branch) if version.commit_hash is None else repo.compare_tree(version.commit_hash) locales.adv_print("BUILDING") if not os.path.exists("gradlew.bat"): with open("gradlew.bat", "w") as f: f.write(requests.get("https://raw.githubusercontent.com/michel-kraemer/gradle-download-task/master/gradlew.bat").text) process = subprocess.Popen(["gradlew.bat", "RatPoison"]) process.communicate() return_code = process.returncode utils.kill_jdk() if return_code == 0: delete_libs_folder() bat_file = utils.get_bat_name() for path in utils.search_file("java.exe"): if utils.verify_path(path): java_exe = str(path) with open(bat_file, "r") as rFile: prev_lines = rFile.readlines() prev_lines[4] = prev_lines[4].replace("java", f"\"{java_exe}\"", 1) with open(bat_file, "w") as wFile: wFile.writelines(prev_lines) break if locales.adv_input("RANDOMIZE_FILE_NAMES_INPUT") in locales.yes: randomize_file_names() replace_bat_path() else: if locales.adv_input("RETRY_BUILD_INPUT"): settings["skip_jdk_checks"] = False settings["force_install_jdk"] = True jdk_tools.download_jdk() compile()
def continue_actions(new_path): utils.kill_jdk() if os.path.exists("jdk-14.0.2"): shutil.move("jdk-14.0.2", new_path) locales.adv_print("MOVING_CFGS") folder_name = utils.get_settings_path() utils.migrate_folder(f"{folder_name}/CFGS", f"{new_path}/settings/CFGS") locales.adv_print("MOVING_HITSOUNDS") utils.migrate_folder(f"{folder_name}/hitsounds", f"{new_path}/settings/hitsounds") locales.adv_print("MOVING_NADEHELPERS") utils.migrate_folder(f"{folder_name}/NadeHelper", f"{new_path}/settings/NadeHelper") locales.adv_print("MOVING_DEFAULT_SETTINGS") utils.migrate_default_settings( f"{folder_name}/", f"{new_path}/settings/CFGS/default_migration.cfg") os.chdir(new_path)
def compile(): if settings["download_missing_files"]: version = repository.Version.get_version_file() repo.compare_tree(version.branch) if version.commit_hash is None else repo.compare_tree(version.commit_hash) locales.adv_print("BUILDING") subprocess.check_call(["gradlew.bat", "RatPoison"]) delete_libs_folder() utils.kill_jdk() bat_file = utils.get_bat_name() for path in utils.search_file("java.exe"): if utils.verify_path(str(path)): java_exe = str(path) with open(bat_file, "r") as rFile: prev_lines = rFile.readlines() prev_lines[4] = prev_lines[4].replace("java", f"\"{java_exe}\"", 1) with open(bat_file, "w") as wFile: wFile.writelines(prev_lines) break if locales.adv_input("RANDOMIZE_FILE_NAMES_INPUT") in locales.yes: randomize_file_names() replace_bat_path()
def on_exit(): utils.kill_jdk()
settings = settingsTools.load_settings() locales = locales.Locales() can_continue = True if os.environ["TEMP"] in os.getcwd(): locales.adv_print("TEMP_FOLDER_EXIT") can_continue = False def on_exit(): utils.kill_jdk() atexit.register(on_exit) # Crash handler if can_continue: try: import main except BaseException: print( "Some exception occured, please report in discord (https://discord.gg/xkTteTM):" ) print("----CUT HERE----") print("Installer settings:") print_json(settings.dict) traceback.print_exc() utils.kill_jdk() os.system("pause")