Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
32 changes: 32 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,31 @@ 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:
# 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
Expand Down
40 changes: 18 additions & 22 deletions src/azure-cli/azure/cli/command_modules/feedback/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down