diff --git a/src/azure-cli-core/azure/cli/core/util.py b/src/azure-cli-core/azure/cli/core/util.py index 5996f110e50..042603552b6 100644 --- a/src/azure-cli-core/azure/cli/core/util.py +++ b/src/azure-cli-core/azure/cli/core/util.py @@ -380,6 +380,13 @@ def _get_version_string(name, version_dict): else: _print(ext.name.ljust(20) + (ext.version or 'Unknown').rjust(20)) _print() + + _print('Dependencies:') + dependencies_versions = get_dependency_versions() + for k, v in dependencies_versions.items(): + _print(k.ljust(20) + v.rjust(20)) + _print() + _print("Python location '{}'".format(os.path.abspath(sys.executable))) _print("Extensions directory '{}'".format(EXTENSIONS_DIR)) if os.path.isdir(EXTENSIONS_SYS_DIR) and os.listdir(EXTENSIONS_SYS_DIR): @@ -415,6 +422,31 @@ def get_az_version_json(): return versions +def get_dependency_versions(): + versions = {} + # Add msal version + try: + from msal import __version__ as msal_version + except ImportError: + msal_version = "N/A" + versions['msal'] = msal_version + + # Add azure-mgmt-resource version + try: + # Track 2 >=15.0.0 + # pylint: disable=protected-access + from azure.mgmt.resource._version import VERSION as azure_mgmt_resource_version + except ImportError: + try: + # Track 1 <=13.0.0 + from azure.mgmt.resource.version import VERSION as azure_mgmt_resource_version + except ImportError: + azure_mgmt_resource_version = "N/A" + versions['azure-mgmt-resource'] = azure_mgmt_resource_version + + return versions + + def show_updates_available(new_line_before=False, new_line_after=False): from azure.cli.core._session import VERSIONS import datetime diff --git a/src/azure-cli/azure/cli/command_modules/feedback/custom.py b/src/azure-cli/azure/cli/command_modules/feedback/custom.py index 672644a5439..60b07909a32 100644 --- a/src/azure-cli/azure/cli/command_modules/feedback/custom.py +++ b/src/azure-cli/azure/cli/command_modules/feedback/custom.py @@ -440,34 +440,30 @@ def _get_az_version_summary(): """ 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() - new_lines = [] - ext_line = -1 - legal_line = -1 + # 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 line.startswith("azure-cli"): - line = " ".join(line.split()) - 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 + if 'extensions:' in line.lower(): + extension_line = i + if 'python location' in line.lower(): + python_line = i break - new_lines.append("") - - if 0 < ext_line < legal_line: - for i in range(ext_line, legal_line): - l_lower = lines[i].lower() - if "python location" in l_lower or "extensions directory" in l_lower: - break - - line = " ".join(lines[i].split()) - new_lines.append(line) + new_lines.extend(lines[extension_line:python_line]) + # Remove last line which is empty + new_lines.pop() return "\n".join(new_lines)