mirror of
https://github.com/ihaveamac/custom-install.git
synced 2025-12-06 06:41:45 +00:00
gui: use list for args instead of creating a string
This commit is contained in:
22
gui.py
22
gui.py
@@ -342,7 +342,7 @@ class gui(tk.Tk):
|
|||||||
run_button.place(relwidth=1, rely=1, y=- 22)
|
run_button.place(relwidth=1, rely=1, y=- 22)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
argstring = ""
|
args_extra = []
|
||||||
|
|
||||||
self.output_to_console("-----------------------\nStarting...\n")
|
self.output_to_console("-----------------------\nStarting...\n")
|
||||||
|
|
||||||
@@ -350,32 +350,33 @@ class gui(tk.Tk):
|
|||||||
if not boot9:
|
if not boot9:
|
||||||
self.output_to_console(
|
self.output_to_console(
|
||||||
"Warning - boot9 not selected, if it's not set externally you may run into problems.\n")
|
"Warning - boot9 not selected, if it's not set externally you may run into problems.\n")
|
||||||
argstring += f"-b {boot9} "
|
else:
|
||||||
|
args_extra.extend(['-b', boot9])
|
||||||
|
|
||||||
sed = self.sed_box.get()
|
sed = self.sed_box.get()
|
||||||
if not sed:
|
if not sed:
|
||||||
self.output_to_console("Failed to run - No movable.sed selected.\n")
|
self.output_to_console("Failed to run - No movable.sed selected.\n")
|
||||||
return
|
return
|
||||||
argstring += f"-m {sed} "
|
args_extra.extend(['-m', sed])
|
||||||
|
|
||||||
sd = self.sd_box.get().strip()
|
sd = self.sd_box.get().strip()
|
||||||
if not sd:
|
if not sd:
|
||||||
self.output_to_console("Failed to run - SD path not selected.\n")
|
self.output_to_console("Failed to run - SD path not selected.\n")
|
||||||
return
|
return
|
||||||
argstring += f"--sd {sd} "
|
args_extra.extend(['--sd', sd])
|
||||||
|
|
||||||
cias = []
|
cias = []
|
||||||
for i in range(0, self.cia_box.size()):
|
for i in range(0, self.cia_box.size()):
|
||||||
cias.append(self.cia_box.get(i).strip())
|
cias.append(self.cia_box.get(i).strip())
|
||||||
for cia in cias:
|
for cia in cias:
|
||||||
argstring += f" {cia}"
|
args_extra.append(cia)
|
||||||
|
|
||||||
if self.skip_contents.get():
|
if self.skip_contents.get():
|
||||||
argstring += "--skip-contents "
|
args_extra.append('--skip-contents')
|
||||||
|
|
||||||
print(f"Running custom-install.py with args {args}\n")
|
print(f"Running custom-install.py with args {args_extra}\n")
|
||||||
|
|
||||||
self.threader.do_async(execute_script, [argstring, self.output_to_console])
|
self.threader.do_async(execute_script, [args_extra, self.output_to_console])
|
||||||
|
|
||||||
def output_to_console(self, outstring):
|
def output_to_console(self, outstring):
|
||||||
self.console.insert('end', outstring)
|
self.console.insert('end', outstring)
|
||||||
@@ -410,12 +411,11 @@ class gui(tk.Tk):
|
|||||||
self.cia_box.select_set(0)
|
self.cia_box.select_set(0)
|
||||||
|
|
||||||
|
|
||||||
def execute_script(argstring, printer):
|
def execute_script(args_extra, printer):
|
||||||
"""Wrapper function to pipe install script output to a printer"""
|
"""Wrapper function to pipe install script output to a printer"""
|
||||||
try:
|
try:
|
||||||
args = [sys.executable, '-u', os.path.join(os.path.dirname(__file__), "custominstall.py")]
|
args = [sys.executable, '-u', os.path.join(os.path.dirname(__file__), "custominstall.py")]
|
||||||
for arg in argstring.split():
|
args.extend(args_extra)
|
||||||
args.append(arg.strip())
|
|
||||||
p = subprocess.Popen(args,
|
p = subprocess.Popen(args,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
|
|||||||
Reference in New Issue
Block a user