Exemple #1
0
def _get_az_version_summary():
    """
    This depends on get_az_version_string not being changed, add some tests to make this and other methods more robust.
    :return: az version info
    """
    az_vers_string = get_az_version_string()[0]

    # Remove consecutive spaces
    import re
    az_vers_string = re.sub(' +', ' ', az_vers_string)

    # Add each line until 'python location'
    lines = az_vers_string.splitlines()

    # First line is azure-cli
    new_lines = [lines[0], '']

    # Only add lines between 'Extensions:' and 'Python location'
    extension_line = -1
    python_line = -1
    for i, line in enumerate(lines):
        if 'extensions:' in line.lower():
            extension_line = i
        if 'python location' in line.lower():
            python_line = i
            break

    new_lines.extend(lines[extension_line:python_line])

    # Remove last line which is empty
    new_lines.pop()
    return "\n".join(new_lines)
Exemple #2
0
def _get_az_version_summary():
    """
    This depends on get_az_version_string not being changed, add some tests to make this and other methods more robust.
    :return: az version info
    """
    az_vers_string = get_az_version_string()[0]

    lines = az_vers_string.splitlines()

    new_lines = []
    ext_line = -1
    legal_line = -1
    for i, line in enumerate(lines):
        if line.startswith("azure-cli"):
            new_lines.append(line)
        if line.lower().startswith("extensions:"):
            ext_line = i
            continue
        l_lower = line.lower()
        if all(["legal" in l_lower, "docs" in l_lower, "info" in l_lower]):
            legal_line = i
            break

    new_lines.append("")

    if 0 < ext_line < legal_line:
        for i in range(ext_line, legal_line):
            new_lines.append(lines[i])

    return "\n".join(new_lines)
Exemple #3
0
 def show_version(self):
     from azure.cli.core.util import get_az_version_string
     ver_string, updates_available = get_az_version_string()
     print(ver_string)
     if updates_available == -1:
         logger.warning('Unable to check if your CLI is up-to-date. Check your internet connection.')
     elif updates_available:
         logger.warning('You have %i updates available. Consider updating your CLI installation.', updates_available)
     else:
         print('Your CLI is up-to-date.')
Exemple #4
0
 def show_version(self):
     from azure.cli.core.util import get_az_version_string
     ver_string, updates_available = get_az_version_string()
     print(ver_string)
     if updates_available == -1:
         logger.warning('Unable to check if your CLI is up-to-date. Check your internet connection.')
     elif updates_available:
         logger.warning('You have %i updates available. Consider updating your CLI installation.', updates_available)
     else:
         print('Your CLI is up-to-date.')
Exemple #5
0
    def show_version(self):
        from azure.cli.core.util import get_az_version_string, show_updates
        from azure.cli.core.commands.constants import (SURVEY_PROMPT, SURVEY_PROMPT_COLOR,
                                                       UX_SURVEY_PROMPT, UX_SURVEY_PROMPT_COLOR)

        ver_string, updates_available = get_az_version_string()
        print(ver_string)
        show_updates(updates_available)

        show_link = self.config.getboolean('output', 'show_survey_link', True)
        if show_link:
            print('\n' + (SURVEY_PROMPT_COLOR if self.enable_color else SURVEY_PROMPT))
            print(UX_SURVEY_PROMPT_COLOR if self.enable_color else UX_SURVEY_PROMPT)
Exemple #6
0
    def show_version(self):
        from azure.cli.core.util import get_az_version_string, show_updates
        from azure.cli.core.commands.constants import SURVEY_PROMPT_STYLED, UX_SURVEY_PROMPT_STYLED
        from azure.cli.core.style import print_styled_text

        ver_string, updates_available_components = get_az_version_string()
        print(ver_string)
        show_updates(updates_available_components)

        show_link = self.config.getboolean('output', 'show_survey_link', True)
        if show_link:
            print_styled_text()
            print_styled_text(SURVEY_PROMPT_STYLED)
            print_styled_text(UX_SURVEY_PROMPT_STYLED)
Exemple #7
0
 def show_version(self):
     from azure.cli.core.util import get_az_version_string
     ver_string, updates_available = get_az_version_string()
     print(ver_string)
     if updates_available == -1:
         logger.warning(
             'Unable to check if your CLI is up-to-date. Check your internet connection.'
         )
     elif updates_available:
         logger.warning(
             'You have %i updates available. Consider updating your CLI installation. '
             'Instructions can be found at https://docs.microsoft.com/en-us/cli/azure/install-azure-cli',
             updates_available)
     else:
         print('Your CLI is up-to-date.')
Exemple #8
0
    def show_version(self):
        from azure.cli.core.util import get_az_version_string
        from azure.cli.core.commands.constants import (SURVEY_PROMPT, SURVEY_PROMPT_COLOR,
                                                       UX_SURVEY_PROMPT, UX_SURVEY_PROMPT_COLOR)

        ver_string, updates_available = get_az_version_string()
        print(ver_string)
        if updates_available == -1:
            logger.warning('Unable to check if your CLI is up-to-date. Check your internet connection.')
        elif updates_available:
            warning_msg = 'You have %i updates available. Consider updating your CLI installation'
            from azure.cli.core._environment import _ENV_AZ_INSTALLER
            installer = os.getenv(_ENV_AZ_INSTALLER)
            instruction_msg = ''
            if installer in _PACKAGE_UPGRADE_INSTRUCTIONS:
                if installer == 'RPM':
                    from azure.cli.core.util import get_linux_distro
                    distname, _ = get_linux_distro()
                    if not distname:
                        instruction_msg = '. {}'.format(_GENERAL_UPGRADE_INSTRUCTION)
                    else:
                        distname = distname.lower().strip()
                        if any(x in distname for x in ['centos', 'rhel', 'red hat', 'fedora']):
                            installer = 'YUM'
                        elif any(x in distname for x in ['opensuse', 'suse', 'sles']):
                            installer = 'ZYPPER'
                        else:
                            instruction_msg = '. {}'.format(_GENERAL_UPGRADE_INSTRUCTION)
                elif installer == 'PIP':
                    import platform
                    system = platform.system()
                    alternative_command = " or '{}' if you used our script for installation. Detailed instructions can be found at {}".format(_PACKAGE_UPGRADE_INSTRUCTIONS[installer][0], _PACKAGE_UPGRADE_INSTRUCTIONS[installer][1]) if system != 'Windows' else ''
                    instruction_msg = " with 'pip install --upgrade azure-cli'{}".format(alternative_command)
                if instruction_msg:
                    warning_msg += instruction_msg
                else:
                    warning_msg += " with '{}'. Detailed instructions can be found at {}".format(_PACKAGE_UPGRADE_INSTRUCTIONS[installer][0], _PACKAGE_UPGRADE_INSTRUCTIONS[installer][1])
            else:
                warning_msg += '. {}'.format(_GENERAL_UPGRADE_INSTRUCTION)
            logger.warning(warning_msg, updates_available)
        else:
            print('Your CLI is up-to-date.')
        show_link = self.config.getboolean('output', 'show_survey_link', True)
        if show_link:
            print('\n' + (SURVEY_PROMPT_COLOR if self.enable_color else SURVEY_PROMPT))
            print(UX_SURVEY_PROMPT_COLOR if self.enable_color else UX_SURVEY_PROMPT)
Exemple #9
0
    def show_version(self):
        from azure.cli.core.util import get_az_version_string
        from azure.cli.core.commands.constants import SURVEY_PROMPT
        import colorama
        ver_string, updates_available = get_az_version_string()
        print(ver_string)
        if updates_available == -1:
            logger.warning('Unable to check if your CLI is up-to-date. Check your internet connection.')
        elif updates_available:
            logger.warning('You have %i updates available. Consider updating your CLI installation. '
                           'Instructions can be found at https://docs.microsoft.com/en-us/cli/azure/install-azure-cli',
                           updates_available)
        else:
            print('Your CLI is up-to-date.')

        colorama.init()  # This could be removed when knack fix is released
        print('\n' + SURVEY_PROMPT)
        colorama.deinit()  # This could be removed when knack fix is released
Exemple #10
0
 def show_version(self):
     from azure.cli.core.util import get_az_version_string
     print(get_az_version_string())
Exemple #11
0
 def show_version(self):
     from azure.cli.core.util import get_az_version_string
     print(get_az_version_string())
Exemple #12
0
 def get_cli_version(self):
     from azure.cli.core.util import get_az_version_string
     return get_az_version_string()
Exemple #13
0
 def get_cli_version(self):
     from azure.cli.core.util import get_az_version_string
     return get_az_version_string()