From faf717dedfafc0ab50faf5b0ca5f4ced3bc0a751 Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Tue, 4 Oct 2022 09:47:44 -0600 Subject: [PATCH] utilities.py: Add error handling in check_boot_mode() --- resources/utilities.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/resources/utilities.py b/resources/utilities.py index 24c6effb8..1ac355775 100644 --- a/resources/utilities.py +++ b/resources/utilities.py @@ -610,8 +610,11 @@ def block_os_updaters(): def check_boot_mode(): # Check whether we're in Safe Mode or not - sys_plist = plistlib.loads(subprocess.run(["system_profiler", "SPSoftwareDataType"], stdout=subprocess.PIPE).stdout) - return sys_plist[0]["_items"][0]["boot_mode"] + try: + sys_plist = plistlib.loads(subprocess.run(["system_profiler", "SPSoftwareDataType"], stdout=subprocess.PIPE).stdout) + return sys_plist[0]["_items"][0]["boot_mode"] + except (KeyError, TypeError, plistlib.InvalidFileException): + return None def elevated(*args, **kwargs) -> subprocess.CompletedProcess: # When running through our GUI, we run as root, however we do not get uid 0