-
Notifications
You must be signed in to change notification settings - Fork 3.3k
{Feedback} Show msal and azure-mgmt-resource versions
#20754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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,29 @@ 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: | ||
| # 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 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also show |
||
|
|
||
| return versions | ||
|
|
||
|
|
||
| def show_updates_available(new_line_before=False, new_line_after=False): | ||
| from azure.cli.core._session import VERSIONS | ||
| import datetime | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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) | ||
|
|
||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no need to parse the output of |
||
| # Remove last line which is empty | ||
| new_lines.pop() | ||
| return "\n".join(new_lines) | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's only add
msalfor now, since the list can go on and on.