From 1abe08bcacf4924d4a765f78e3de2238c3bfaac5 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk <48863253+khronokernel@users.noreply.github.com> Date: Sat, 15 May 2021 18:07:17 -0600 Subject: [PATCH] Fix screen clear erroring in RecoveryOS --- OpenCore-Patcher.command | 3 +++ Resources/Utilities.py | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/OpenCore-Patcher.command b/OpenCore-Patcher.command index 15412359b..627741908 100755 --- a/OpenCore-Patcher.command +++ b/OpenCore-Patcher.command @@ -57,6 +57,9 @@ class OpenCoreLegacyPatcher(): self.constants.custom_cpu_model_value = custom_cpu_model_value.split("%00")[0] # Check if running in RecoveryOS + self.check_recovery() + + def check_recovery(self): root_partition_info = plistlib.loads(subprocess.run("diskutil info -plist /".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) if root_partition_info["VolumeName"] == "macOS Base System" and \ root_partition_info["FilesystemType"] == "apfs" and \ diff --git a/Resources/Utilities.py b/Resources/Utilities.py index 9b3f7281e..ba602aebc 100644 --- a/Resources/Utilities.py +++ b/Resources/Utilities.py @@ -3,8 +3,8 @@ from __future__ import print_function import os import math as m - -from Resources import Constants +import plistlib +import subprocess def header(lines): lines = [i for i in lines if i is not None] @@ -15,10 +15,18 @@ def header(lines): print("#" + " " * left_side + line.strip() + " " * (total_length - len("#" + " " * left_side + line.strip()) - 1) + "#") print("#" * total_length) +def check_recovery(): + root_partition_info = plistlib.loads(subprocess.run("diskutil info -plist /".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()) + if root_partition_info["VolumeName"] == "macOS Base System" and \ + root_partition_info["FilesystemType"] == "apfs" and \ + root_partition_info["BusProtocol"] == "Disk Image": + return True + else: + return False def cls(): # RecoveryOS doesn't support terminal clearing - if Constants.Constants().recovery_status == False: + if check_recovery() == False: os.system('cls' if os.name == 'nt' else 'clear') else: # Default terminal window is 24 lines tall