gui_main.py: Add disk highlighting during install

This commit is contained in:
Mykola Grymalyuk
2022-04-26 21:24:45 -06:00
parent 4b5f1b4016
commit 3340f10fbd
7 changed files with 78 additions and 4 deletions
+1
View File
@@ -192,6 +192,7 @@ class Constants:
self.allow_nvme_fixing = True # Allow NVMe Kernel Space Patches
self.disable_xcpm = False # Disable XCPM (X86PlatformPlugin.kext)
self.root_patcher_succeded = False # Determine if root patcher succeeded
self.booted_oc_disk = None # Determine current disk OCLP booted from
self.legacy_accel_support = [
os_data.os_data.mojave,
+2
View File
@@ -475,6 +475,7 @@ class Computer:
cpu: Optional[CPU] = None
oclp_version: Optional[str] = None
opencore_version: Optional[str] = None
opencore_path: Optional[str] = None
bluetooth_chipset: Optional[str] = None
ambient_light_sensor: Optional[bool] = False
third_party_sata_ssd: Optional[bool] = False
@@ -696,6 +697,7 @@ class Computer:
# OCLP version
self.oclp_version = utilities.get_nvram("OCLP-Version", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True)
self.opencore_version = utilities.get_nvram("opencore-version", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True)
self.opencore_path = utilities.get_nvram("boot-path", "4D1FDA02-38C7-4A6A-9CC6-4BCCA8B30102", decode=True)
def cpu_probe(self):
self.cpu = CPU(
+1
View File
@@ -30,6 +30,7 @@ class OpenCoreLegacyPatcher:
self.constants.computer = device_probe.Computer.probe()
self.constants.recovery_status = utilities.check_recovery()
self.computer = self.constants.computer
self.constants.booted_oc_disk = utilities.find_disk_off_uuid(utilities.clean_device_path(self.computer.opencore_path))
launcher_script = None
launcher_binary = sys.executable
if "python" in launcher_binary:
+38
View File
@@ -403,6 +403,44 @@ def download_file(link, location, is_gui=None, verify_checksum=False):
print(link)
return None
def dump_constants(constants):
with open(os.path.join(os.path.expanduser('~'), 'Desktop', 'internal_data.txt'), 'w') as f:
f.write(str(vars(constants)))
def clean_device_path(device_path: str):
# ex:
# 'PciRoot(0x0)/Pci(0xA,0x0)/Sata(0x0,0x0,0x0)/HD(1,GPT,C0778F23-3765-4C8E-9BFA-D60C839E7D2D,0x28,0x64000)/EFI\OC\OpenCore.efi'
# 'PciRoot(0x0)/Pci(0x1A,0x7)/USB(0x0,0x0)/USB(0x2,0x0)/HD(2,GPT,4E929909-2074-43BA-9773-61EBC110A670,0x64800,0x38E3000)/EFI\OC\OpenCore.efi'
# return:
# 'C0778F23-3765-4C8E-9BFA-D60C839E7D2D'
# '4E929909-2074-43BA-9773-61EBC110A670'
if device_path:
device_path_array = device_path.split("/")
# we can always assume [-1] is 'EFI\OC\OpenCore.efi'
if len(device_path_array) >= 2:
device_path_stripped = device_path_array[-2]
device_path_root_array = device_path_stripped.split(",")
return device_path_root_array[2]
return None
def find_disk_off_uuid(uuid):
# Find disk by UUID
disk_list = None
try:
disk_list = plistlib.loads(subprocess.run(["diskutil", "info", "-plist", uuid], stdout=subprocess.PIPE).stdout)
except TypeError:
pass
if disk_list:
try:
return disk_list["DeviceIdentifier"]
except KeyError:
pass
return None
def grab_mount_point_from_disk(disk):
data = plistlib.loads(subprocess.run(f"diskutil info -plist {disk}".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())
return data["MountPoint"]