From e72daf90b8c99efbe17af2f08537d85dded241bf Mon Sep 17 00:00:00 2001 From: "J.P" <70083705+stapmoshun@users.noreply.github.com> Date: Thu, 26 Oct 2023 15:03:48 -0400 Subject: [PATCH] towards brew --- cloudmesh/common/Shell.py | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/cloudmesh/common/Shell.py b/cloudmesh/common/Shell.py index 0d1b47eb..59d38881 100755 --- a/cloudmesh/common/Shell.py +++ b/cloudmesh/common/Shell.py @@ -581,7 +581,7 @@ def install_brew(): content = """#!/bin/bash - pw="$(osascript -e 'Tell application "System Events" to display dialog "Password:" default answer "" with hidden answer' -e 'text returned of result' 2>/dev/null)" && echo "$pw" + pw="$(osascript -e 'Tell application "System Events" to display dialog "Please enter your macOS password to install Homebrew:" default answer "" with hidden answer' -e 'text returned of result' 2>/dev/null)" && echo "$pw" """ askpass = os.path.expanduser('~/pw.sh') @@ -595,21 +595,29 @@ def install_brew(): # command = 'NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' command = f'osascript -e \'tell application "Terminal" to do script "/bin/bash -c \\"export SUDO_ASKPASS={askpass} ; export NONINTERACTIVE=1 ; $(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\\""\'' print(command) - try: - subprocess.run(command, shell=True, check=True) - print("Homebrew installed successfully.") - except subprocess.CalledProcessError as e: - print(f"Error while installing Homebrew: {e}") + # try: + subprocess.run(command, shell=True, check=True) + # print("Homebrew installed successfully.") + # except subprocess.CalledProcessError as e: + # print(f"Error while installing Homebrew: {e}") + + while True: - try: - r = subprocess.check_output("brew --version", - stderr=subprocess.STDOUT, - shell=True) - Console.ok("Homebrew installed") - return True - except subprocess.CalledProcessError: - Console.error("Homebrew could not be installed.") - return False + try: + r = subprocess.check_output("brew --version", + stderr=subprocess.STDOUT, + shell=True) + Console.ok("Homebrew installed") + return True + except subprocess.CalledProcessError: + print('Waiting', end=' ') + from time import sleep + sleep(2) + continue + # Console.error("Homebrew could not be installed.") + # return False + + Shell.rm(askpass) @staticmethod