From af3abe6aa1f16730904e5f63ab28e7eca9c55fce Mon Sep 17 00:00:00 2001 From: Mykola Grymalyuk Date: Tue, 25 Jan 2022 09:55:21 -0700 Subject: [PATCH] installer.py: Add Permissions check --- resources/installer.py | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/resources/installer.py b/resources/installer.py index 71dd80668..3432de590 100644 --- a/resources/installer.py +++ b/resources/installer.py @@ -12,26 +12,29 @@ def list_local_macOS_installers(): for application in Path("/Applications").iterdir(): # Verify whether application has createinstallmedia - if (Path("/Applications") / Path(application) / Path("Contents/Resources/createinstallmedia")).exists(): - plist = plistlib.load((Path("/Applications") / Path(application) / Path("Contents/Info.plist")).open("rb")) - try: - # Doesn't reflect true OS build, but best to report SDK in the event multiple installers are found with same version - app_version = plist["DTPlatformVersion"] - clean_name = plist["CFBundleDisplayName"] + try: + if (Path("/Applications") / Path(application) / Path("Contents/Resources/createinstallmedia")).exists(): + plist = plistlib.load((Path("/Applications") / Path(application) / Path("Contents/Info.plist")).open("rb")) try: - app_sdk = plist["DTSDKBuild"] + # Doesn't reflect true OS build, but best to report SDK in the event multiple installers are found with same version + app_version = plist["DTPlatformVersion"] + clean_name = plist["CFBundleDisplayName"] + try: + app_sdk = plist["DTSDKBuild"] + except KeyError: + app_sdk = "Unknown" + application_list.update({ + application: { + "Short Name": clean_name, + "Version": app_version, + "Build": app_sdk, + "Path": application, + } + }) except KeyError: - app_sdk = "Unknown" - application_list.update({ - application: { - "Short Name": clean_name, - "Version": app_version, - "Build": app_sdk, - "Path": application, - } - }) - except KeyError: - pass + pass + except PermissionError: + pass return application_list def create_installer(installer_path, volume_name):