mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-03 19:28:25 +02:00
added try except in most function to help debugging error
This commit is contained in:
parent
1b7bb6ec1f
commit
e4fa9ba95c
9 changed files with 315 additions and 280 deletions
2
main.pyw
2
main.pyw
|
@ -3,6 +3,7 @@ from PIL import Image, ImageFont, ImageDraw
|
||||||
from tkinter import messagebox, filedialog, ttk
|
from tkinter import messagebox, filedialog, ttk
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import traceback
|
||||||
import requests
|
import requests
|
||||||
import zipfile
|
import zipfile
|
||||||
import shutil
|
import shutil
|
||||||
|
@ -26,6 +27,7 @@ class ClassApp():
|
||||||
from source.restart import restart
|
from source.restart import restart
|
||||||
from source.patch_img_desc import patch_img_desc
|
from source.patch_img_desc import patch_img_desc
|
||||||
from source.patch_ct_icon import patch_ct_icon
|
from source.patch_ct_icon import patch_ct_icon
|
||||||
|
from source.log_error import log_error
|
||||||
|
|
||||||
|
|
||||||
App = ClassApp()
|
App = ClassApp()
|
||||||
|
|
|
@ -6,13 +6,17 @@ import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
VERSION_FILE_URL = "https://raw.githubusercontent.com/Faraphel/MKWF-Install/master/version"
|
VERSION_FILE_URL = "https://raw.githubusercontent.com/Faraphel/MKWF-Install/master/version"
|
||||||
|
|
||||||
|
|
||||||
def check_update(self):
|
def check_update(self):
|
||||||
try:
|
try:
|
||||||
gitversion = requests.get(VERSION_FILE_URL, allow_redirects=True).json()
|
gitversion = requests.get(VERSION_FILE_URL, allow_redirects=True).json()
|
||||||
with open("version", "rb") as f:
|
with open("./version", "rb") as f:
|
||||||
locversion = json.load(f)
|
locversion = json.load(f)
|
||||||
|
|
||||||
if float(gitversion["version"]) > float(locversion["version"]):
|
if ((float(gitversion["version"]) > float(locversion["version"])) or
|
||||||
|
(float(gitversion["version"]) == float(locversion["version"])) and
|
||||||
|
float(gitversion["subversion"]) > float(locversion["subversion"])):
|
||||||
if messagebox.askyesno(self.translate("Mise à jour disponible !"), self.translate("Une mise à jour est disponible, souhaitez-vous l'installer ?") +
|
if messagebox.askyesno(self.translate("Mise à jour disponible !"), self.translate("Une mise à jour est disponible, souhaitez-vous l'installer ?") +
|
||||||
f"\n\nVersion : {locversion['version']}.{locversion['subversion']} -> {gitversion['version']}.{gitversion['subversion']}\n"+\
|
f"\n\nVersion : {locversion['version']}.{locversion['subversion']} -> {gitversion['version']}.{gitversion['subversion']}\n"+\
|
||||||
f"Changelog :\n{gitversion['changelog']}"):
|
f"Changelog :\n{gitversion['changelog']}"):
|
||||||
|
@ -34,5 +38,5 @@ def check_update(self):
|
||||||
os.startfile(os.path.realpath("./Updater/Updater.exe"))
|
os.startfile(os.path.realpath("./Updater/Updater.exe"))
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
except Exception as e:
|
except:
|
||||||
print(e)
|
self.log_error()
|
||||||
|
|
|
@ -2,6 +2,7 @@ import json
|
||||||
|
|
||||||
|
|
||||||
def create_lecode_config(self):
|
def create_lecode_config(self):
|
||||||
|
try:
|
||||||
def get_star_text(track):
|
def get_star_text(track):
|
||||||
if "warning" in track: warning = "!" * track["warning"]
|
if "warning" in track: warning = "!" * track["warning"]
|
||||||
else: warning = ""
|
else: warning = ""
|
||||||
|
@ -72,3 +73,6 @@ def create_lecode_config(self):
|
||||||
for _ in range(1, 4-(i%4)): # Complete cup if track are missing
|
for _ in range(1, 4-(i%4)): # Complete cup if track are missing
|
||||||
ctfile.write(f' T T44; T44; 0x00; "_"; ""; "-"\n')
|
ctfile.write(f' T T44; T44; 0x00; "_"; ""; "-"\n')
|
||||||
rctfile.write(f' T T44; T44; 0x00; "_"; ""; "-"\n')
|
rctfile.write(f' T T44; T44; 0x00; "_"; ""; "-"\n')
|
||||||
|
|
||||||
|
except:
|
||||||
|
self.log_error()
|
||||||
|
|
|
@ -11,6 +11,7 @@ from .definition import *
|
||||||
|
|
||||||
def install_mod(self):
|
def install_mod(self):
|
||||||
def func():
|
def func():
|
||||||
|
try:
|
||||||
with open("./fs.json") as f:
|
with open("./fs.json") as f:
|
||||||
fs = json.load(f)
|
fs = json.load(f)
|
||||||
|
|
||||||
|
@ -88,10 +89,11 @@ def install_mod(self):
|
||||||
self.Progress(statut=self.translate("Patch lecode-PAL.bin"), add=1)
|
self.Progress(statut=self.translate("Patch lecode-PAL.bin"), add=1)
|
||||||
|
|
||||||
subprocess.call(
|
subprocess.call(
|
||||||
["./tools/szs/wlect", "patch", "./file/lecode-PAL.bin", "-od", self.path_mkwf + "/files/rel/lecode-PAL.bin",
|
["./tools/szs/wlect", "patch", "./file/lecode-PAL.bin", "-od", self.path_mkwf +
|
||||||
"--track-dir", self.path_mkwf + "/files/Race/Course/", "--copy-tracks", "./file/Track/",
|
"/files/rel/lecode-PAL.bin", "--track-dir", self.path_mkwf + "/files/Race/Course/", "--copy-tracks",
|
||||||
"--move-tracks", self.path_mkwf + "/files/Race/Course/", "--le-define",
|
"./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)
|
"./file/CTFILE.txt", "--lpar", "./file/lpar-default.txt", "--overwrite"]
|
||||||
|
, creationflags=CREATE_NO_WINDOW)
|
||||||
|
|
||||||
outputformat = self.listbox_outputformat.get()
|
outputformat = self.listbox_outputformat.get()
|
||||||
self.Progress(statut=self.translate("Conversion en")+f" {outputformat}", add=1)
|
self.Progress(statut=self.translate("Conversion en")+f" {outputformat}", add=1)
|
||||||
|
@ -110,6 +112,9 @@ def install_mod(self):
|
||||||
self.Progress(show=False)
|
self.Progress(show=False)
|
||||||
messagebox.showinfo(self.translate("Fin"), self.translate("L'installation est terminé !"))
|
messagebox.showinfo(self.translate("Fin"), self.translate("L'installation est terminé !"))
|
||||||
|
|
||||||
|
except:
|
||||||
|
self.log_error()
|
||||||
|
|
||||||
t = Thread(target=func)
|
t = Thread(target=func)
|
||||||
t.setDaemon(True)
|
t.setDaemon(True)
|
||||||
t.start()
|
t.start()
|
||||||
|
|
4
source/log_error.py
Normal file
4
source/log_error.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
def log_error(self, exception):
|
||||||
|
with open("error.log", "a") as f: f.write(f"---\n{traceback.format_exc()}\n")
|
|
@ -85,6 +85,7 @@ trackname_color = {
|
||||||
}
|
}
|
||||||
|
|
||||||
def patch_bmg(self, gamefile): # gamefile est le fichier .szs trouvé dans le /files/Scene/UI/ du jeu
|
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
|
bmglang = gamefile[-len("E.txt"):-len(".txt")] # Langue du fichier
|
||||||
self.Progress(statut=self.translate("Patch des textes " + bmglang), add=1)
|
self.Progress(statut=self.translate("Patch des textes " + bmglang), add=1)
|
||||||
|
|
||||||
|
@ -144,3 +145,6 @@ def patch_bmg(self, gamefile): # gamefile est le fichier .szs trouvé dans le /
|
||||||
|
|
||||||
finalise(f"./file/Common_{bmglang}.txt", bmgtext)
|
finalise(f"./file/Common_{bmglang}.txt", bmgtext)
|
||||||
finalise(f"./file/Common_R{bmglang}.txt", rbmgtext)
|
finalise(f"./file/Common_R{bmglang}.txt", rbmgtext)
|
||||||
|
|
||||||
|
except:
|
||||||
|
self.log_error()
|
||||||
|
|
|
@ -5,6 +5,7 @@ import os
|
||||||
|
|
||||||
|
|
||||||
def patch_ct_icon(self):
|
def patch_ct_icon(self):
|
||||||
|
try:
|
||||||
with open("./ct_config.json", encoding="utf8") as f: config = json.load(f)
|
with open("./ct_config.json", encoding="utf8") as f: config = json.load(f)
|
||||||
|
|
||||||
cup_number = len(config["cup"]) + math.ceil(len(config["tracks_list"]) / 4)
|
cup_number = len(config["cup"]) + math.ceil(len(config["tracks_list"]) / 4)
|
||||||
|
@ -39,3 +40,6 @@ def patch_ct_icon(self):
|
||||||
ct_icon.paste(cup_icon, (0, i * 128))
|
ct_icon.paste(cup_icon, (0, i * 128))
|
||||||
|
|
||||||
ct_icon.save("./file/ct_icons.tpl.png")
|
ct_icon.save("./file/ct_icons.tpl.png")
|
||||||
|
|
||||||
|
except:
|
||||||
|
self.log_error()
|
||||||
|
|
|
@ -9,6 +9,7 @@ from .definition import *
|
||||||
|
|
||||||
def patch_file(self):
|
def patch_file(self):
|
||||||
def func():
|
def func():
|
||||||
|
try:
|
||||||
if os.path.exists("./file/Track-WU8/"):
|
if os.path.exists("./file/Track-WU8/"):
|
||||||
total_track = len(os.listdir("./file/Track-WU8/"))
|
total_track = len(os.listdir("./file/Track-WU8/"))
|
||||||
else:
|
else:
|
||||||
|
@ -69,6 +70,9 @@ def patch_file(self):
|
||||||
self.button_install_mod.grid(row=2, column=1, sticky="NEWS")
|
self.button_install_mod.grid(row=2, column=1, sticky="NEWS")
|
||||||
self.listbox_outputformat.grid(row=2, column=2, sticky="NEWS")
|
self.listbox_outputformat.grid(row=2, column=2, sticky="NEWS")
|
||||||
|
|
||||||
|
except:
|
||||||
|
self.log_error()
|
||||||
|
|
||||||
t = Thread(target=func)
|
t = Thread(target=func)
|
||||||
t.setDaemon(True)
|
t.setDaemon(True)
|
||||||
t.start()
|
t.start()
|
||||||
|
|
|
@ -5,6 +5,7 @@ from .definition import *
|
||||||
|
|
||||||
|
|
||||||
def patch_img_desc(self):
|
def patch_img_desc(self):
|
||||||
|
try:
|
||||||
il = Image.open("./file/img_desc/illustration.png")
|
il = Image.open("./file/img_desc/illustration.png")
|
||||||
il_16_9 = il.resize((832, 456))
|
il_16_9 = il.resize((832, 456))
|
||||||
il_4_3 = il.resize((608, 456))
|
il_4_3 = il.resize((608, 456))
|
||||||
|
@ -23,3 +24,6 @@ def patch_img_desc(self):
|
||||||
new_4_3.paste(il_4_3, (0, 0), il_4_3)
|
new_4_3.paste(il_4_3, (0, 0), il_4_3)
|
||||||
new_4_3.paste(img_lang_4_3, (0, 0), img_lang_4_3)
|
new_4_3.paste(img_lang_4_3, (0, 0), img_lang_4_3)
|
||||||
new_4_3.save(f"./file/strapA_608x456{get_filename(get_nodir(file_lang))}.png")
|
new_4_3.save(f"./file/strapA_608x456{get_filename(get_nodir(file_lang))}.png")
|
||||||
|
|
||||||
|
except:
|
||||||
|
self.log_error()
|
||||||
|
|
Loading…
Reference in a new issue