allow roms with spaces to be extracted (#868)

using subprocess instead of os.system() is a little safer, and allows
for roms with spaces to be extraced.

i've noticed this is somewhat common in people reporting issues on
discord.
This commit is contained in:
Jeffrey Crowell 2022-07-21 19:12:43 -04:00 committed by GitHub
parent 235cef6abf
commit 753031df17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ import shutil
from rom_info import Z64Rom from rom_info import Z64Rom
import rom_chooser import rom_chooser
import struct import struct
import subprocess
def BuildOTR(xmlPath, rom): def BuildOTR(xmlPath, rom):
shutil.copytree("assets", "Extract/assets") shutil.copytree("assets", "Extract/assets")
@ -13,11 +14,13 @@ def BuildOTR(xmlPath, rom):
with open("Extract/version", "wb") as f: with open("Extract/version", "wb") as f:
f.write(struct.pack('<L', checksum)) f.write(struct.pack('<L', checksum))
execStr = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPDTR/ZAPD.out" zapd_exe = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPDTR/ZAPD.out"
execStr += " ed -i %s -b %s -fl CFG/filelists -o placeholder -osf placeholder -gsf 1 -rconf CFG/Config.xml -se OTR" % (xmlPath, rom) exec_cmd = [zapd_exe, "ed", "-i", xmlPath, "-b", rom, "-fl", "CFG/filelists",
"-o", "placeholder", "-osf", "placeholder", "-gsf", "1",
"-rconf", "CFG/Config.xml", "-se", "OTR"]
print(execStr) print(exec_cmd)
exitValue = os.system(execStr) exitValue = subprocess.call(exec_cmd)
if exitValue != 0: if exitValue != 0:
print("\n") print("\n")
print("Error when building the OTR file...", file=os.sys.stderr) print("Error when building the OTR file...", file=os.sys.stderr)