From 02325876917d19810eee9838071cc0d95bc9e86e Mon Sep 17 00:00:00 2001 From: raphael60650 Date: Tue, 15 Jun 2021 21:28:03 +0200 Subject: [PATCH] now using subprocess.run instead of subprocess.call or subprocess.check_output --- source/install_mod.py | 33 ++++++++++++++++++--------------- source/patch_bmg.py | 28 ++++++++++++++-------------- source/patch_file.py | 8 ++++---- 3 files changed, 36 insertions(+), 33 deletions(-) diff --git a/source/install_mod.py b/source/install_mod.py index 5bc191a..1444cd2 100644 --- a/source/install_mod.py +++ b/source/install_mod.py @@ -49,9 +49,9 @@ def install_mod(self): if extension == "szs": if not (os.path.realpath(path) in extracted_file): - subprocess.check_output(["./tools/szs/wszst", "EXTRACT", get_nodir(path), "-d", - get_nodir(path) + ".d", "--overwrite"], - creationflags=CREATE_NO_WINDOW, cwd=get_dir(path)) + subprocess.run(["./tools/szs/wszst", "EXTRACT", get_nodir(path), "-d", get_nodir(path) + ".d", + "--overwrite"], creationflags=CREATE_NO_WINDOW, cwd=get_dir(path), + check=True, stdout=subprocess.PIPE) extracted_file.append(os.path.realpath(path)) szs_extract_path = path + ".d" @@ -79,14 +79,15 @@ def install_mod(self): for file in extracted_file: self.Progress(statut=self.translate("Recompilation de")+f"\n{get_nodir(file)}", add=1) - subprocess.check_output(["./tools/szs/wszst", "CREATE", get_nodir(file) + ".d", "-d", get_nodir(file), - "--overwrite"], creationflags=CREATE_NO_WINDOW, cwd=get_dir(file)) + subprocess.run(["./tools/szs/wszst", "CREATE", get_nodir(file) + ".d", "-d", get_nodir(file), + "--overwrite"], creationflags=CREATE_NO_WINDOW, cwd=get_dir(file), + check=True, stdout=subprocess.PIPE) if os.path.exists(file + ".d"): shutil.rmtree(file + ".d") self.Progress(statut=self.translate("Patch main.dol"), add=1) - subprocess.check_output(["./tools/szs/wstrt", "patch", get_nodir(self.path_mkwf) + "/sys/main.dol", - "--clean-dol", "--add-lecode"], creationflags=CREATE_NO_WINDOW, - cwd=get_dir(self.path_mkwf)) + subprocess.run(["./tools/szs/wstrt", "patch", get_nodir(self.path_mkwf) + "/sys/main.dol", "--clean-dol", + "--add-lecode"], creationflags=CREATE_NO_WINDOW, cwd=get_dir(self.path_mkwf), + check=True, stdout=subprocess.PIPE) self.Progress(statut=self.translate("Patch lecode-PAL.bin"), add=1) @@ -96,11 +97,11 @@ def install_mod(self): filecopy("./file/lpar-default.txt", self.path_mkwf + "/tmp/lpar-default.txt") filecopy("./file/lecode-PAL.bin", self.path_mkwf + "/tmp/lecode-PAL.bin") - subprocess.check_output( + subprocess.run( ["./tools/szs/wlect", "patch", "./tmp/lecode-PAL.bin", "-od", "./files/rel/lecode-PAL.bin", "--track-dir", "./files/Race/Course/", "--move-tracks", "./files/Race/Course/", "--le-define", "./tmp/CTFILE.txt", "--lpar", "./tmp/lpar-default.txt", "--overwrite"], - creationflags=CREATE_NO_WINDOW, cwd=self.path_mkwf) + creationflags=CREATE_NO_WINDOW, cwd=self.path_mkwf, check=True, stdout=subprocess.PIPE) shutil.rmtree(self.path_mkwf + "/tmp/") @@ -109,14 +110,16 @@ def install_mod(self): if outputformat in ["ISO", "WBFS", "CISO"]: self.path_mkwf_format = os.path.realpath(self.path_mkwf + "/../MKWFaraphel." + outputformat.lower()) - subprocess.check_output(["./tools/wit/wit", "COPY", get_nodir(self.path_mkwf), "--DEST", - get_nodir(self.path_mkwf_format), f"--{outputformat.lower()}", "--overwrite"], - creationflags=CREATE_NO_WINDOW, cwd=get_dir(self.path_mkwf)) + subprocess.run(["./tools/wit/wit", "COPY", get_nodir(self.path_mkwf), "--DEST", + get_nodir(self.path_mkwf_format), f"--{outputformat.lower()}", "--overwrite"], + CREATE_NO_WINDOW, cwd=get_dir(self.path_mkwf), + check=True, stdout=subprocess.PIPE) shutil.rmtree(self.path_mkwf) self.Progress(statut=self.translate("Changement de l'ID du jeu"), add=1) - subprocess.check_output(["./tools/wit/wit", "EDIT", get_dir(self.path_mkwf_format), "--id", "RMCP60"], - creationflags=CREATE_NO_WINDOW, cwd=get_dir(self.path_mkwf_format)) + subprocess.run(["./tools/wit/wit", "EDIT", get_dir(self.path_mkwf_format), "--id", "RMCP60"], + creationflags=CREATE_NO_WINDOW, cwd=get_dir(self.path_mkwf_format), + check=True, stdout=subprocess.PIPE) messagebox.showinfo(self.translate("Fin"), self.translate("L'installation est terminé !")) diff --git a/source/patch_bmg.py b/source/patch_bmg.py index 17e7702..3a70a6d 100644 --- a/source/patch_bmg.py +++ b/source/patch_bmg.py @@ -84,17 +84,19 @@ trackname_color = { "★☆☆!! ": "\c{YOR6}★☆☆\c{off} ", } + def patch_bmg(self, gamefile): # gamefile est le fichier .szs trouvé dans le /files/Scene/UI/ du jeu try: bmglang = gamefile[-len("E.txt"):-len(".txt")] # Langue du fichier self.Progress(statut=self.translate("Patch des textes " + bmglang), add=1) - subprocess.call(["./tools/szs/wszst", "EXTRACT", get_nodir(gamefile), "-d", get_nodir(gamefile) + ".d", - "--overwrite"], creationflags=CREATE_NO_WINDOW, cwd=get_dir(gamefile)) + subprocess.run(["./tools/szs/wszst", "EXTRACT", get_nodir(gamefile), "-d", get_nodir(gamefile) + ".d", + "--overwrite"], creationflags=CREATE_NO_WINDOW, cwd=get_dir(gamefile)) # Common.bmg - bmgtracks = subprocess.check_output(["./tools/szs/wbmgt", "CAT", get_nodir(gamefile) + ".d/message/Common.bmg"], - creationflags=CREATE_NO_WINDOW, cwd=get_dir(gamefile)) + bmgtracks = subprocess.run(["./tools/szs/wbmgt", "CAT", get_nodir(gamefile) + ".d/message/Common.bmg"], + creationflags=CREATE_NO_WINDOW, cwd=get_dir(gamefile), + check=True, stdout=subprocess.PIPE).stdout bmgtracks = bmgtracks.decode() trackheader = "#--- standard track names" trackend = "2328" @@ -128,14 +130,12 @@ def patch_bmg(self, gamefile): # gamefile est le fichier .szs trouvé dans le / if not(os.path.exists("./file/tmp/")): os.makedirs("./file/tmp/") filecopy(gamefile+".d/message/Common.bmg", "./file/tmp/Common.bmg") - bmgtext = subprocess.check_output(["tools/szs/wctct", "bmg", "--le-code", "--long", "./file/CTFILE.txt", - "--patch-bmg", "OVERWRITE=./file/tmp/Common.bmg", - "--patch-bmg", "OVERWRITE=./file/ExtraCommon.txt"], - creationflags=CREATE_NO_WINDOW).decode() - rbmgtext = subprocess.check_output(["tools/szs/wctct", "bmg", "--le-code", "--long", "./file/RCTFILE.txt", - "--patch-bmg", "OVERWRITE=./file/tmp/Common.bmg", - "--patch-bmg", "OVERWRITE=./file/ExtraCommon.txt"], - creationflags=CREATE_NO_WINDOW).decode() + bmgtext = subprocess.run(["tools/szs/wctct", "bmg", "--le-code", "--long", "./file/CTFILE.txt", "--patch-bmg", + "OVERWRITE=./file/tmp/Common.bmg", "--patch-bmg", "OVERWRITE=./file/ExtraCommon.txt"], + creationflags=CREATE_NO_WINDOW, check=True, stdout=subprocess.PIPE).stdout.decode() + rbmgtext = subprocess.run(["tools/szs/wctct", "bmg", "--le-code", "--long", "./file/RCTFILE.txt", "--patch-bmg", + "OVERWRITE=./file/tmp/Common.bmg", "--patch-bmg", "OVERWRITE=./file/ExtraCommon.txt"], + creationflags=CREATE_NO_WINDOW, check=True, stdout=subprocess.PIPE).stdout.decode() shutil.rmtree(gamefile + ".d") os.remove("./file/tmp/Common.bmg") @@ -144,8 +144,8 @@ def patch_bmg(self, gamefile): # gamefile est le fichier .szs trouvé dans le / def finalise(common_file, bmgtext): for console in trackname_color: bmgtext = bmgtext.replace(console, trackname_color[console]) with open(common_file, "w", encoding="utf-8") as f: f.write(bmgtext) - subprocess.call(["./tools/szs/wbmgt", "ENCODE", get_nodir(common_file), "--overwrite"], - creationflags=CREATE_NO_WINDOW, cwd=get_dir(common_file)) + subprocess.run(["./tools/szs/wbmgt", "ENCODE", get_nodir(common_file), "--overwrite"], + creationflags=CREATE_NO_WINDOW, cwd=get_dir(common_file)) os.remove(common_file) finalise(f"./file/Common_{bmglang}.txt", bmgtext) diff --git a/source/patch_file.py b/source/patch_file.py index 787df42..b6b6b99 100644 --- a/source/patch_file.py +++ b/source/patch_file.py @@ -30,15 +30,15 @@ def patch_file(self): for i, file in enumerate(fc["img"]): self.Progress(statut=self.translate("Conversion des images")+f"\n({i + 1}/{len(fc['img'])}) {file}", add=1) - subprocess.call(["./tools/szs/wimgt", "ENCODE", "./file/" + file, "-x", fc["img"][file], "--overwrite"] - , creationflags=CREATE_NO_WINDOW) + subprocess.run(["./tools/szs/wimgt", "ENCODE", "./file/" + file, "-x", fc["img"][file], "--overwrite"], + creationflags=CREATE_NO_WINDOW) for file in glob.glob(self.path_mkwf+"/files/Scene/UI/MenuSingle_?.szs"): self.patch_bmg(file) if not(os.path.exists("./file/auto-add/")): - subprocess.call(["./tools/szs/wszst", "AUTOADD", self.path_mkwf + "/files/Race/Course/", "--DEST", - "./file/auto-add/"], creationflags=CREATE_NO_WINDOW) + subprocess.run(["./tools/szs/wszst", "AUTOADD", self.path_mkwf + "/files/Race/Course/", "--DEST", + "./file/auto-add/"], creationflags=CREATE_NO_WINDOW) max_process = 8 process_list = {}