mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-05 20:28:27 +02:00
subprocess call will now be working with path as relative with a cwd to avoid special character
This commit is contained in:
parent
8fdce2d4f5
commit
7e221c7b5e
6 changed files with 86 additions and 62 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -87,3 +87,4 @@
|
|||
/build/
|
||||
/test/
|
||||
/distribution.txt
|
||||
/error.log
|
||||
|
|
|
@ -52,6 +52,7 @@ def __init__(self):
|
|||
|
||||
def use_path():
|
||||
def func():
|
||||
try:
|
||||
self.frame_action.grid_forget()
|
||||
path = entry_game_path.get()
|
||||
if not (os.path.exists(path)):
|
||||
|
@ -65,15 +66,17 @@ def __init__(self):
|
|||
"Êtes-vous sûr de vouloir l'utiliser ?")):
|
||||
self.path_mkwf = os.path.realpath(path + "/../../")
|
||||
elif extension.upper() in ["ISO", "WBFS", "WIA", "CSIO"]:
|
||||
self.path_mkwf, i = os.path.realpath(path + "/../MKWiiFaraphel"), 1
|
||||
directory_name, i = "MKWiiFaraphel", 1
|
||||
|
||||
while True:
|
||||
self.path_mkwf = os.path.realpath(path + f"/../{directory_name}")
|
||||
if not(os.path.exists(self.path_mkwf)): break
|
||||
self.path_mkwf, i = os.path.realpath(path + f"/../MKWiiFaraphel ({i})"), i + 1
|
||||
directory_name, i = f"MKWiiFaraphel ({i})", i + 1
|
||||
|
||||
|
||||
self.Progress(show=True, indeter=True, statut=self.translate("Extraction du jeu..."))
|
||||
subprocess.call(["./tools/wit/wit", "EXTRACT", path, "--DEST", self.path_mkwf]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
subprocess.call(["./tools/wit/wit", "EXTRACT", get_nodir(path), "--DEST", directory_name]
|
||||
, creationflags=CREATE_NO_WINDOW, cwd=get_dir(path))
|
||||
self.Progress(show=False)
|
||||
|
||||
else:
|
||||
|
@ -86,6 +89,8 @@ def __init__(self):
|
|||
self.translate("Cette ROM est déjà moddé, " +
|
||||
"il est déconseillé de l'utiliser pour installer le mod"))
|
||||
|
||||
except: self.log_error()
|
||||
finally:
|
||||
self.frame_action.grid(row=3, column=1, sticky="NEWS")
|
||||
self.Progress(show=False)
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
get_filename = lambda file: ".".join(file.split(".")[:-1])
|
||||
get_nodir = lambda file: file.split("/")[-1].split("\\")[-1]
|
||||
get_nodir = lambda file: file.replace("\\", "/").split("/")[-1]
|
||||
get_dir = lambda file: "/".join(file.replace("\\", "/").split("/")[:-1])
|
||||
get_extension = lambda file: file.split(".")[-1]
|
||||
|
||||
CREATE_NO_WINDOW = 0x08000000
|
||||
|
|
|
@ -49,8 +49,9 @@ def install_mod(self):
|
|||
|
||||
if extension == "szs":
|
||||
if not (os.path.realpath(path) in extracted_file):
|
||||
subprocess.call(["./tools/szs/wszst", "EXTRACT", path, "-d", path + ".d", "--overwrite"]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
subprocess.check_output(["./tools/szs/wszst", "EXTRACT", get_nodir(path), "-d",
|
||||
get_nodir(path) + ".d", "--overwrite"],
|
||||
creationflags=CREATE_NO_WINDOW, cwd=get_dir(path))
|
||||
extracted_file.append(os.path.realpath(path))
|
||||
|
||||
szs_extract_path = path + ".d"
|
||||
|
@ -78,42 +79,50 @@ def install_mod(self):
|
|||
|
||||
for file in extracted_file:
|
||||
self.Progress(statut=self.translate("Recompilation de")+f"\n{get_nodir(file)}", add=1)
|
||||
subprocess.call(["./tools/szs/wszst", "CREATE", file + ".d", "-d", file,
|
||||
"--overwrite"], creationflags=CREATE_NO_WINDOW)
|
||||
subprocess.check_output(["./tools/szs/wszst", "CREATE", get_nodir(file) + ".d", "-d", get_nodir(file),
|
||||
"--overwrite"], creationflags=CREATE_NO_WINDOW, cwd=get_dir(file))
|
||||
if os.path.exists(file + ".d"): shutil.rmtree(file + ".d")
|
||||
|
||||
self.Progress(statut=self.translate("Patch main.dol"), add=1)
|
||||
subprocess.call(["./tools/szs/wstrt", "patch", self.path_mkwf + "/sys/main.dol", "--clean-dol",
|
||||
"--add-lecode"], creationflags=CREATE_NO_WINDOW)
|
||||
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))
|
||||
|
||||
self.Progress(statut=self.translate("Patch lecode-PAL.bin"), add=1)
|
||||
|
||||
subprocess.call(
|
||||
["./tools/szs/wlect", "patch", "./file/lecode-PAL.bin", "-od", self.path_mkwf +
|
||||
"/files/rel/lecode-PAL.bin", "--track-dir", self.path_mkwf + "/files/Race/Course/", "--copy-tracks",
|
||||
"./file/Track/", "--move-tracks", self.path_mkwf + "/files/Race/Course/", "--le-define",
|
||||
"./file/CTFILE.txt", "--lpar", "./file/lpar-default.txt", "--overwrite"]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
shutil.copytree("./file/Track/", self.path_mkwf+"/files/Race/Course/", dirs_exist_ok=True)
|
||||
if not(os.path.exists(self.path_mkwf+"/tmp/CTFILE.txt")): os.makedirs(self.path_mkwf+"/tmp/CTFILE.txt")
|
||||
filecopy("./file/CTFILE.txt", self.path_mkwf+"/tmp/CTFILE.txt")
|
||||
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(
|
||||
["./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)
|
||||
|
||||
shutil.rmtree(self.path_mkwf + "/files/Race/Course/")
|
||||
shutil.rmtree(self.path_mkwf + "/tmp/")
|
||||
|
||||
outputformat = self.listbox_outputformat.get()
|
||||
self.Progress(statut=self.translate("Conversion en")+f" {outputformat}", add=1)
|
||||
|
||||
if outputformat in ["ISO", "WBFS", "CISO"]:
|
||||
self.path_mkwf_format = os.path.realpath(self.path_mkwf + "/../MKWFaraphel." + outputformat.lower())
|
||||
subprocess.call(["./tools/wit/wit", "COPY", self.path_mkwf, "--DEST",
|
||||
self.path_mkwf_format, f"--{outputformat.lower()}", "--overwrite"]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
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))
|
||||
shutil.rmtree(self.path_mkwf)
|
||||
|
||||
self.Progress(statut=self.translate("Changement de l'ID du jeu"), add=1)
|
||||
subprocess.call(["./tools/wit/wit", "EDIT", self.path_mkwf_format, "--id", "RMCP60"]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
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))
|
||||
|
||||
self.Progress(show=False)
|
||||
messagebox.showinfo(self.translate("Fin"), self.translate("L'installation est terminé !"))
|
||||
|
||||
except:
|
||||
self.log_error()
|
||||
except: self.log_error()
|
||||
finally: self.Progress(show=False)
|
||||
|
||||
t = Thread(target=func)
|
||||
t.setDaemon(True)
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
import traceback
|
||||
from tkinter import messagebox
|
||||
|
||||
def log_error(self, exception):
|
||||
with open("./error.log", "a") as f: f.write(f"---\n{traceback.format_exc()}\n")
|
||||
def log_error(self):
|
||||
error = traceback.format_exc()
|
||||
with open("./error.log", "a") as f: f.write(f"---\n{error}\n")
|
||||
messagebox.showerror(self.translate("Erreur"), self.translate("Une erreur est survenue :") + f"\n{error}\n\n")
|
|
@ -89,12 +89,12 @@ def patch_bmg(self, gamefile): # gamefile est le fichier .szs trouvé dans le /
|
|||
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", gamefile, "-d", gamefile + ".d", "--overwrite"]
|
||||
, creationflags=CREATE_NO_WINDOW)
|
||||
subprocess.call(["./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", gamefile + ".d/message/Common.bmg"],
|
||||
creationflags=CREATE_NO_WINDOW)
|
||||
bmgtracks = subprocess.check_output(["./tools/szs/wbmgt", "CAT", get_nodir(gamefile) + ".d/message/Common.bmg"],
|
||||
creationflags=CREATE_NO_WINDOW, cwd=get_dir(gamefile))
|
||||
bmgtracks = bmgtracks.decode()
|
||||
trackheader = "#--- standard track names"
|
||||
trackend = "2328"
|
||||
|
@ -125,22 +125,27 @@ def patch_bmg(self, gamefile): # gamefile est le fichier .szs trouvé dans le /
|
|||
Tname = bmgtrack[bmgtrack.find("= ") + 2:]
|
||||
f.write(f" {Tid}\t= {prefix}{Tname}\n")
|
||||
|
||||
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=" + gamefile + ".d/message/Common.bmg",
|
||||
"--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=" + gamefile + ".d/message/Common.bmg",
|
||||
"--patch-bmg", "OVERWRITE=./file/tmp/Common.bmg",
|
||||
"--patch-bmg", "OVERWRITE=./file/ExtraCommon.txt"],
|
||||
creationflags=CREATE_NO_WINDOW).decode()
|
||||
|
||||
shutil.rmtree(gamefile + ".d")
|
||||
os.remove("./file/tmp/Common.bmg")
|
||||
os.remove("./file/ExtraCommon.txt")
|
||||
|
||||
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", common_file, "--overwrite"], creationflags=CREATE_NO_WINDOW)
|
||||
subprocess.call(["./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)
|
||||
|
|
Loading…
Reference in a new issue