mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-03 19:28:25 +02:00
auto-add will now always regenerate
if track is corrupted, it will be reconverted if too much track aren't properly converted, the installation stop.
This commit is contained in:
parent
0fb8eb0b8f
commit
ae5e3e5987
1 changed files with 41 additions and 27 deletions
|
@ -1,6 +1,7 @@
|
||||||
from tkinter import messagebox
|
from tkinter import messagebox
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import shutil
|
||||||
import json
|
import json
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
@ -37,10 +38,14 @@ def patch_file(self):
|
||||||
for file in glob.glob(self.path_mkwf+"/files/Scene/UI/MenuSingle_?.szs"):
|
for file in glob.glob(self.path_mkwf+"/files/Scene/UI/MenuSingle_?.szs"):
|
||||||
self.patch_bmg(file)
|
self.patch_bmg(file)
|
||||||
|
|
||||||
if not(os.path.exists("./file/auto-add/")):
|
shutil.rmtree("./file/auto-add")
|
||||||
|
if not(os.path.exists(self.path_mkwf + "/tmp/")): os.makedirs(self.path_mkwf + "/tmp/")
|
||||||
subprocess.run(["./tools/szs/wszst", "AUTOADD", get_nodir(self.path_mkwf) + "/files/Race/Course/",
|
subprocess.run(["./tools/szs/wszst", "AUTOADD", get_nodir(self.path_mkwf) + "/files/Race/Course/",
|
||||||
"--DEST", "./file/auto-add/"], creationflags=CREATE_NO_WINDOW,
|
"--DEST", get_nodir(self.path_mkwf) + "/tmp/auto-add/"],
|
||||||
cwd=get_dir(self.path_mkwf), check=True, stdout=subprocess.PIPE)
|
creationflags=CREATE_NO_WINDOW, cwd=get_dir(self.path_mkwf),
|
||||||
|
check=True, stdout=subprocess.PIPE)
|
||||||
|
shutil.move(self.path_mkwf + "/tmp/auto-add/", "./file/auto-add/")
|
||||||
|
shutil.rmtree(self.path_mkwf + "/tmp/")
|
||||||
|
|
||||||
max_process = 8
|
max_process = 8
|
||||||
process_list = {}
|
process_list = {}
|
||||||
|
@ -53,29 +58,34 @@ def patch_file(self):
|
||||||
self.Progress(statut=self.translate("Conversion des courses")+f"\n({i + 1}/{total_track})\n" +
|
self.Progress(statut=self.translate("Conversion des courses")+f"\n({i + 1}/{total_track})\n" +
|
||||||
"\n".join(process_list.keys()), add=1)
|
"\n".join(process_list.keys()), add=1)
|
||||||
|
|
||||||
if not(os.path.exists("./file/Track/" + get_filename(file) + ".szs")):
|
track_szs_file = f"./file/Track/{get_filename(file)}.szs"
|
||||||
|
if os.path.exists(track_szs_file):
|
||||||
|
if os.path.getsize(track_szs_file) < 1000: # File under this size are corrupted
|
||||||
|
os.remove(track_szs_file)
|
||||||
|
|
||||||
|
if not(os.path.exists(track_szs_file)):
|
||||||
process_list[file] = subprocess.Popen([
|
process_list[file] = subprocess.Popen([
|
||||||
"./tools/szs/wszst", "NORMALIZE", "./file/Track-WU8/" + file, "--DEST",
|
"./tools/szs/wszst", "NORMALIZE", "./file/Track-WU8/" + file, "--DEST",
|
||||||
"./file/Track/%N.szs", "--szs", "--overwrite", "--autoadd-path",
|
"./file/Track/%N.szs", "--szs", "--overwrite", "--autoadd-path",
|
||||||
"./file/auto-add/"], creationflags=CREATE_NO_WINDOW)
|
"./file/auto-add/"], creationflags=CREATE_NO_WINDOW, stderr=subprocess.PIPE)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
for process in process_list:
|
for process in process_list:
|
||||||
if process_list[process] is not None:
|
if process_list[process] is not None:
|
||||||
returncode = process_list[process].poll()
|
returncode = process_list[process].poll()
|
||||||
if not(returncode == 0):
|
if returncode is None: pass # if the process is still running
|
||||||
process_list.pop(process)
|
else: # process ended
|
||||||
break
|
stderr = process_list[process].stderr.read()
|
||||||
else:
|
if b"wszst: ERROR" in stderr: # Error occured
|
||||||
process_list.pop(process)
|
process_list.pop(process)
|
||||||
os.remove(f"./file/Track/{get_filename(process)}.szs")
|
os.remove(f"./file/Track/{get_filename(process)}.szs")
|
||||||
error_count += 1
|
error_count += 1
|
||||||
if error_count > error_max:
|
if error_count > error_max: # Too much track wasn't correctly converted
|
||||||
messagebox.showerror(
|
messagebox.showerror(
|
||||||
self.translate("Erreur"),
|
self.translate("Erreur"),
|
||||||
self.translate("Trop de course ont eu une erreur de conversion."))
|
self.translate("Trop de course ont eu une erreur de conversion."))
|
||||||
return
|
return
|
||||||
else:
|
else: # if the error max hasn't been reach
|
||||||
messagebox.showwarning(
|
messagebox.showwarning(
|
||||||
self.translate("Attention"),
|
self.translate("Attention"),
|
||||||
self.translate("La course ") +
|
self.translate("La course ") +
|
||||||
|
@ -83,16 +93,20 @@ def patch_file(self):
|
||||||
self.translate(" n'a pas été correctement converti. (") +
|
self.translate(" n'a pas été correctement converti. (") +
|
||||||
str(error_count) + "/"+str(error_max)+")")
|
str(error_count) + "/"+str(error_max)+")")
|
||||||
break
|
break
|
||||||
|
|
||||||
|
else:
|
||||||
|
process_list.pop(process)
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
process_list.pop(process)
|
process_list.pop(process)
|
||||||
break
|
break
|
||||||
|
|
||||||
self.Progress(show=False)
|
|
||||||
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:
|
except: self.log_error()
|
||||||
self.log_error()
|
finally: self.Progress(show=False)
|
||||||
|
|
||||||
|
|
||||||
t = Thread(target=func)
|
t = Thread(target=func)
|
||||||
t.setDaemon(True)
|
t.setDaemon(True)
|
||||||
|
|
Loading…
Reference in a new issue