From 32b225ca7fcc45ba0127ae9f92d8d3cc9d24835a Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov <47745270+al-cheb@users.noreply.github.com> Date: Fri, 25 Feb 2022 10:55:47 +0300 Subject: [PATCH] Anka close Python 2.7 window (#5135) --- .../provision/configuration/configure-machine.sh | 2 +- .../macos/provision/configuration/finalize-vm.sh | 2 +- images/macos/provision/core/python.sh | 5 +++++ images/macos/provision/utils/utils.sh | 15 ++++++++++++++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/images/macos/provision/configuration/configure-machine.sh b/images/macos/provision/configuration/configure-machine.sh index e9c193d6e..8cbf869c8 100644 --- a/images/macos/provision/configuration/configure-machine.sh +++ b/images/macos/provision/configuration/configure-machine.sh @@ -13,7 +13,7 @@ sudo rm -f /var/vm/sleepimage defaults write NSGlobalDomain NSAppSleepDisabled -bool YES # Disable Keyboard Setup Assistant window -if [ -d "/Library/Application Support/Veertu" ]; then +if is_Veertu; then sudo defaults write /Library/Preferences/com.apple.keyboardtype "keyboardtype" -dict-add "3-7582-0" -int 40 fi diff --git a/images/macos/provision/configuration/finalize-vm.sh b/images/macos/provision/configuration/finalize-vm.sh index e7af07eb3..acc498f9a 100644 --- a/images/macos/provision/configuration/finalize-vm.sh +++ b/images/macos/provision/configuration/finalize-vm.sh @@ -3,7 +3,7 @@ source ~/utils/utils.sh # Close all finder windows because they can interfere with UI tests -osascript -e 'tell application "Finder" to close windows' +close_finder_window if is_Catalina; then # Ignore available updates to prevent system pop-ups diff --git a/images/macos/provision/core/python.sh b/images/macos/provision/core/python.sh index 9c83caf99..1cd2fd83d 100755 --- a/images/macos/provision/core/python.sh +++ b/images/macos/provision/core/python.sh @@ -12,6 +12,11 @@ pip install --upgrade pip echo "Install Python2 certificates" bash -c "/Applications/Python\ 2.7/Install\ Certificates.command" +# Close Finder window +if is_Veertu; then + close_finder_window +fi + # Explicitly overwrite symlinks created by Python2 such as /usr/local/bin/2to3 since they conflict with symlinks from Python3 # https://github.com/actions/virtual-environments/issues/2322 echo "Brew Installing Python 3" diff --git a/images/macos/provision/utils/utils.sh b/images/macos/provision/utils/utils.sh index 4b844a41e..a3ee128b7 100755 --- a/images/macos/provision/utils/utils.sh +++ b/images/macos/provision/utils/utils.sh @@ -71,6 +71,14 @@ is_Less_Monterey() { fi } +is_Veertu() { + if [ -d "/Library/Application Support/Veertu" ]; then + true + else + false + fi +} + get_toolset_path() { echo "$HOME/image-generation/toolset.json" } @@ -192,4 +200,9 @@ get_github_package_download_url() { downloadUrl=$(echo $json | jq -r ".[] | select(.tag_name==\"${tagName}\").assets[].browser_download_url | select(${FILTER})" | head -n 1) echo $downloadUrl -} \ No newline at end of file +} + +# Close all finder windows because they can interfere with UI tests +close_finder_window() { + osascript -e 'tell application "Finder" to close windows' +}