Swtich to py-applescript library

This commit is contained in:
Mykola Grymalyuk
2023-05-17 12:45:24 -06:00
parent 96fcba8391
commit 7417fc4180
4 changed files with 85 additions and 102 deletions

View File

@@ -6,6 +6,7 @@ import subprocess
import tempfile
import enum
import logging
import applescript
from data import os_data
from resources import network_handler, utilities
@@ -53,19 +54,16 @@ class InstallerCreation():
"""
logging.info("- Extracting macOS installer from InstallAssistant.pkg\n This may take some time")
args = [
"osascript",
"-e",
f'''do shell script "installer -pkg {Path(download_path)}/InstallAssistant.pkg -target /"'''
' with prompt "OpenCore Legacy Patcher needs administrator privileges to add InstallAssistant."'
" with administrator privileges"
" without altering line endings",
]
result = subprocess.run(args,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if result.returncode != 0:
try:
applescript.AppleScript(
f'''do shell script "installer -pkg {Path(download_path)}/InstallAssistant.pkg -target /"'''
' with prompt "OpenCore Legacy Patcher needs administrator privileges to add InstallAssistant."'
" with administrator privileges"
" without altering line endings",
).run()
except Exception as e:
logging.info("- Failed to install InstallAssistant")
logging.info(f" Error Code: {result.returncode}")
logging.info(f" Error Code: {e}")
return False
logging.info("- InstallAssistant installed")