GUI: Revert helper usage

This commit is contained in:
Mykola Grymalyuk
2023-05-17 19:34:52 -06:00
parent 2d5ea95ee0
commit fa711c18cc
2 changed files with 35 additions and 18 deletions
+16 -6
View File
@@ -217,22 +217,32 @@ class RelaunchApplicationAsRoot:
return
timer: int = 5
program_arguments: list = []
program_arguments: str = ""
if event:
if event.GetEventObject() != wx.Menu:
try:
if event.GetEventObject().GetLabel() in ["Start Root Patching", "Reinstall Root Patches"]:
program_arguments += ["--gui_patch"]
program_arguments = " --gui_patch"
elif event.GetEventObject().GetLabel() == "Revert Root Patches":
program_arguments += ["--gui_unpatch"]
program_arguments = " --gui_unpatch"
except TypeError:
pass
if self.constants.launcher_script is None:
program_arguments = [self.constants.launcher_binary] + program_arguments
program_arguments = f"'{self.constants.launcher_binary}'{program_arguments}"
else:
program_arguments = [self.constants.launcher_binary, self.constants.launcher_script] + program_arguments
program_arguments = f"{self.constants.launcher_binary} {self.constants.launcher_script}{program_arguments}"
# Relaunch as root
args = [
"osascript",
"-e",
f'''do shell script "{program_arguments}"'''
' with prompt "OpenCore Legacy Patcher needs administrator privileges to relaunch as admin."'
" with administrator privileges"
" without altering line endings",
]
self.frame.DestroyChildren()
self.frame.SetSize(400, 300)
@@ -253,7 +263,7 @@ class RelaunchApplicationAsRoot:
wx.GetApp().Yield()
logging.info(f"- Relaunching as root with command: {program_arguments}")
subprocess.Popen([self.constants.oclp_helper_path, *program_arguments], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while True:
wx.GetApp().Yield()