* Install script improvements

- Check anaconda and improve tab completion set up
- Clearer message for native dependencies
- Change SHA256

* Change shasum
This commit is contained in:
Derek Bekoe 2017-04-10 10:04:36 -07:00 коммит произвёл GitHub
Родитель 80a7b9a1ae
Коммит 37a20be3d7
2 изменённых файлов: 25 добавлений и 9 удалений

Просмотреть файл

@ -9,7 +9,7 @@
# Bash script to install the Azure CLI
#
INSTALL_SCRIPT_URL="https://azurecliprod.blob.core.windows.net/install.py"
INSTALL_SCRIPT_SHA256=097a294e3e200870e250fcb57ada74f06de94b2929f3f347ae0afd78323fafa5
INSTALL_SCRIPT_SHA256=9fc71faaa27588835b56c22e39860627be097352354b7fcb062da4e833989630
_TTY=/dev/tty
install_script=$(mktemp -t azure_cli_install_tmp_XXXX) || exit

Просмотреть файл

@ -203,6 +203,14 @@ def _get_default_rc_file():
return USER_BASH_PROFILE
return USER_BASH_RC if bashrc_exists else None
def _default_rc_file_creation_step():
rcfile = USER_BASH_PROFILE if platform.system().lower() == 'darwin' else USER_BASH_RC
ans_yes = prompt_y_n('Could not automatically find a suitable file to use. Create {} now?'.format(rcfile), default='y')
if ans_yes:
open(rcfile, 'a').close()
return rcfile
return None
def _find_line_in_file(file_path, search_pattern):
try:
with open(file_path, 'r') as search_file:
@ -224,14 +232,17 @@ def create_tab_completion_file(filename):
print_status("Created tab completion file at '{}'".format(filename))
def get_rc_file_path():
rc_file_path = None
while not rc_file_path:
rc_file = prompt_input_with_default('Enter a path to an rc file to update', _get_default_rc_file())
rc_file = None
default_rc_file = _get_default_rc_file()
if not default_rc_file:
rc_file = _default_rc_file_creation_step()
rc_file = rc_file or prompt_input_with_default('Enter a path to an rc file to update', default_rc_file)
if rc_file:
rc_file_path = os.path.realpath(os.path.expanduser(rc_file))
if not os.path.isfile(rc_file_path):
# Ask user again as it is not a file
rc_file_path = None
return rc_file_path
if os.path.isfile(rc_file_path):
return rc_file_path
print_status("The file '{}' could not be found.".format(rc_file_path))
return None
def warn_other_azs_on_path(exec_dir, exec_filepath):
env_path = os.environ.get('PATH')
@ -251,6 +262,8 @@ def handle_path_and_tab_completion(completion_file_path, exec_filepath, exec_dir
ans_yes = prompt_y_n('Modify profile to update your $PATH and enable shell/tab completion now?', 'y')
if ans_yes:
rc_file_path = get_rc_file_path()
if not rc_file_path:
raise CLIInstallError('No suitable profile file found.')
_backup_rc(rc_file_path)
line_to_add = "export PATH=$PATH:{}".format(exec_dir)
_modify_rc(rc_file_path, line_to_add)
@ -271,6 +284,9 @@ def verify_python_version():
v = sys.version_info
if v < (2, 7):
raise CLIInstallError('The CLI does not support Python versions less than 2.7.')
if 'conda' in sys.version:
raise CLIInstallError("This script does not support the Python Anaconda environment. "
"Create an Anaconda virtual environment and install with 'pip'")
print_status('Python version {}.{}.{} okay.'.format(v.major, v.minor, v.micro))
def _native_dependencies_for_dist(verify_cmd_args, install_cmd_args, dep_list):
@ -282,7 +298,7 @@ def _native_dependencies_for_dist(verify_cmd_args, install_cmd_args, dep_list):
err_msg = 'One or more of the following native dependencies are not currently installed and may be required.\n'
err_msg += '"{}"'.format(' '.join(install_cmd_args + dep_list))
print_status(err_msg)
ans_yes = prompt_y_n('Attempt to continue anyway?', 'n')
ans_yes = prompt_y_n('Missing native dependencies. Attempt to continue anyway?', 'n')
if not ans_yes:
raise CLIInstallError('Please install the native dependencies and try again.')