sys_patch: Avoid relaunching OCLP

This commit is contained in:
Mykola Grymalyuk
2024-05-28 12:23:33 -06:00
parent 3d8d97f400
commit fdfc86e0d6
2 changed files with 11 additions and 21 deletions

View File

@@ -162,10 +162,6 @@ Please check the Github page for more information about this release."""
patch_string += f"- {patch}\n" patch_string += f"- {patch}\n"
logging.info("- No new binaries found on Github, proceeding with patching") logging.info("- No new binaries found on Github, proceeding with patching")
if self.constants.launcher_script is None:
args_string = f"'{self.constants.launcher_binary}' --gui_patch"
else:
args_string = f"{self.constants.launcher_binary} {self.constants.launcher_script} --gui_patch"
warning_str = "" warning_str = ""
if network_handler.NetworkUtilities("https://api.github.com/repos/dortania/OpenCore-Legacy-Patcher/releases/latest").verify_network_connection() is False: if network_handler.NetworkUtilities("https://api.github.com/repos/dortania/OpenCore-Legacy-Patcher/releases/latest").verify_network_connection() is False:
@@ -183,20 +179,9 @@ Please check the Github page for more information about this release."""
stderr=subprocess.STDOUT stderr=subprocess.STDOUT
) )
if output.returncode == 0: if output.returncode == 0:
args = [ gui_entry.EntryPoint(self.constants).start(entry=gui_entry.SupportedEntryPoints.SYS_PATCH, start_patching=True)
"/usr/bin/osascript",
"-e",
f'''do shell script "{args_string}"'''
f' with prompt "OpenCore Legacy Patcher would like to patch your root volume"'
" with administrator privileges"
" without altering line endings"
]
subprocess.run(
args,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT
)
return return
else: else:
logging.info("- No patches detected") logging.info("- No patches detected")
else: else:

View File

@@ -47,14 +47,19 @@ class EntryPoint:
self.app = wx.App() self.app = wx.App()
self.app.SetAppName(self.constants.patcher_name) self.app.SetAppName(self.constants.patcher_name)
# Reference:
# - https://discuss.wxpython.org/t/macos-window-opens-in-the-background-and-does-not-receive-focus/36763/10
NSApplication.sharedApplication()
NSApp().activateIgnoringOtherApps_(True)
def start(self, entry: SupportedEntryPoints = gui_main_menu.MainFrame) -> None:
def start(self, entry: SupportedEntryPoints = gui_main_menu.MainFrame, start_patching: bool = False) -> None:
""" """
Launches entry point for the wxPython GUI Launches entry point for the wxPython GUI
""" """
self._generate_base_data() self._generate_base_data()
if "--gui_patch" in sys.argv or "--gui_unpatch" in sys.argv: if "--gui_patch" in sys.argv or "--gui_unpatch" in sys.argv or start_patching is True :
entry = gui_sys_patch_start.SysPatchStartFrame entry = gui_sys_patch_start.SysPatchStartFrame
patches = sys_patch_detect.DetectRootPatch(self.constants.computer.real_model, self.constants).detect_patch_set() patches = sys_patch_detect.DetectRootPatch(self.constants.computer.real_model, self.constants).detect_patch_set()
@@ -68,12 +73,12 @@ class EntryPoint:
title=f"{self.constants.patcher_name} {self.constants.patcher_version}{' (Nightly)' if not self.constants.commit_info[0].startswith('refs/tags') else ''}", title=f"{self.constants.patcher_name} {self.constants.patcher_version}{' (Nightly)' if not self.constants.commit_info[0].startswith('refs/tags') else ''}",
global_constants=self.constants, global_constants=self.constants,
screen_location=None, screen_location=None,
**({"patches": patches} if "--gui_patch" in sys.argv or "--gui_unpatch" in sys.argv else {}) **({"patches": patches} if "--gui_patch" in sys.argv or "--gui_unpatch" in sys.argv or start_patching is True else {})
) )
atexit.register(self.OnCloseFrame) atexit.register(self.OnCloseFrame)
if "--gui_patch" in sys.argv: if "--gui_patch" in sys.argv or start_patching is True:
self.frame.start_root_patching() self.frame.start_root_patching()
elif "--gui_unpatch" in sys.argv: elif "--gui_unpatch" in sys.argv:
self.frame.revert_root_patching() self.frame.revert_root_patching()