Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/azure-cli-core/azure/cli/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -415,6 +422,29 @@ def get_az_version_json():
return versions


def get_dependency_versions():
versions = {}
# Add msal version
try:
from msal import __version__ as msal_version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would work!

By the way, do you consider also printing MSAL EX? :-)

I'm still providing an approval for this part. Other Azure CLI teammates please help review the rest of this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, do you consider also printing MSAL EX? :-)

Let's only add msal for now, since the list can go on and on.

except ImportError:
msal_version = "N/A"
versions['msal'] = msal_version

# Add azure-mgmt-resource version
try:
# pylint: disable=protected-access
from azure.mgmt.resource._version import VERSION as azure_mgmt_resource_version
except ImportError:
try:
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also show azure-mgmt-resource version because some packages will install Track 1 SDKs, causing conflict with Azure CLI.


return versions


def show_updates_available(new_line_before=False, new_line_after=False):
from azure.cli.core._session import VERSIONS
import datetime
Expand Down
35 changes: 11 additions & 24 deletions src/azure-cli/azure/cli/command_modules/feedback/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from azure.cli.core.azlogging import _UNKNOWN_COMMAND, _CMD_LOG_LINE_PREFIX
from azure.cli.core.commands.constants import SURVEY_PROMPT
from azure.cli.core.extension._resolve import resolve_project_url_from_index, NoExtensionCandidatesError
from azure.cli.core.util import get_az_version_string, open_page_in_browser, can_launch_browser, in_cloud_console
from azure.cli.core.util import get_az_version_string, open_page_in_browser, can_launch_browser, in_cloud_console, \
get_dependency_versions
from knack.log import get_logger
from knack.prompting import prompt, NoTTYException
from knack.util import CLIError
Expand Down Expand Up @@ -440,34 +441,20 @@ def _get_az_version_summary():
"""
az_vers_string = get_az_version_string()[0]

lines = az_vers_string.splitlines()
# 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
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 'python location' in line.lower():
break
new_lines.append(line)

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)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to parse the output of az --version in such detail. Simply remove consecutive spaces and it will work, given we don't need to minify the body of az feedback anymore (#17353).

# Remove last line which is empty
new_lines.pop()
return "\n".join(new_lines)


Expand Down