Skip to content

Commit

Permalink
add debug
Browse files Browse the repository at this point in the history
  • Loading branch information
fengzhou-msft committed Aug 17, 2020
1 parent ad2f965 commit fa07120
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/azure-cli-core/azure/cli/core/extension/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def update_extension(cmd=None, extension_name=None, index_url=None, pip_extra_in
ext = get_extension(extension_name, ext_type=WheelExtension)
cur_version = ext.get_version()
try:
source, ext_sha256 = resolve_from_index(extension_name, cur_version=cur_version, index_url=index_url)
download_url, ext_sha256 = resolve_from_index(extension_name, cur_version=cur_version, index_url=index_url)
except NoExtensionCandidatesError as err:
logger.debug(err)
msg = "No updates available for '{}'. Use --debug for more information.".format(extension_name)
Expand All @@ -310,7 +310,7 @@ def update_extension(cmd=None, extension_name=None, index_url=None, pip_extra_in
shutil.rmtree(extension_path)
# Install newer version
try:
_add_whl_ext(cli_ctx=cmd_cli_ctx, source=source, ext_sha256=ext_sha256,
_add_whl_ext(cli_ctx=cmd_cli_ctx, source=download_url, ext_sha256=ext_sha256,
pip_extra_index_urls=pip_extra_index_urls, pip_proxy=pip_proxy)
logger.debug('Deleting backup of old extension at %s', backup_dir)
shutil.rmtree(backup_dir)
Expand Down
8 changes: 8 additions & 0 deletions src/azure-cli/azure/cli/command_modules/extension/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,11 @@
- name: Update an extension by name and use pip proxy for dependencies
text: az extension update --name anextension --pip-proxy https://user:pass@proxy.server:8080
"""

helps['extension list-versions'] = """
type: command
short-summary: List available versions for an extension.
examples:
- name: List available versions for an extension
text: az extension list-versions --name anextension
"""
12 changes: 9 additions & 3 deletions src/azure-cli/azure/cli/command_modules/util/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def upgrade_version(cmd, update_all=None, yes=None): # pylint: disable=too-many
apt_update_cmd.insert(0, 'sudo')
az_update_cmd.insert(0, 'sudo')
subprocess.call(apt_update_cmd)
logger.debug("Update azure cli with '%s'", " ".join(apt_update_cmd))
exit_code = subprocess.call(az_update_cmd)
elif installer == 'RPM':
from azure.cli.core.util import get_linux_distro
Expand All @@ -90,6 +91,7 @@ def upgrade_version(cmd, update_all=None, yes=None): # pylint: disable=too-many
update_cmd = 'yum update -y azure-cli'.split()
if os.geteuid() != 0: # pylint: disable=no-member
update_cmd.insert(0, 'sudo')
logger.debug("Update azure cli with '%s'", " ".join(update_cmd))
exit_code = subprocess.call(update_cmd)
elif any(x in distname for x in ['opensuse', 'suse', 'sles']):
zypper_refresh_cmd = ['zypper', 'refresh']
Expand All @@ -98,22 +100,26 @@ def upgrade_version(cmd, update_all=None, yes=None): # pylint: disable=too-many
zypper_refresh_cmd.insert(0, 'sudo')
az_update_cmd.insert(0, 'sudo')
subprocess.call(zypper_refresh_cmd)
logger.debug("Update azure cli with '%s'", " ".join(az_update_cmd))
exit_code = subprocess.call(az_update_cmd)
else:
logger.warning(UPGRADE_MSG)
elif installer == 'HOMEBREW':
logger.warning("Update homebrew formulae")
subprocess.call(['brew', 'update'])
exit_code = subprocess.call(['brew', 'upgrade', 'azure-cli'])
update_cmd = ['brew', 'upgrade', 'azure-cli']
logger.debug("Update azure cli with '%s'", " ".join(update_cmd))
exit_code = subprocess.call(update_cmd)
elif installer == 'PIP':
pip_args = [sys.executable, '-m', 'pip', 'install', '--upgrade', 'azure-cli', '-vv',
'--disable-pip-version-check', '--no-cache-dir']
logger.debug('Executing pip with args: %s', pip_args)
logger.debug("Update azure cli with '%s'", " ".join(pip_args))
exit_code = subprocess.call(pip_args, shell=platform.system() == 'Windows')
elif installer == 'DOCKER':
logger.warning("Exit the container to pull latest image with 'docker pull mcr.microsoft.com/azure-cli' "
"or 'pip install --upgrade azure-cli' in this container")
"or run 'pip install --upgrade azure-cli' in this container")
elif installer == 'MSI':
logger.debug("Update azure cli with MSI from https://aka.ms/installazurecliwindows")
exit_code = subprocess.call(['powershell.exe', 'Start-Process powershell -Wait -Verb runAs -ArgumentList "Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile AzureCLI.msi;Start-Process msiexec.exe -Wait -ArgumentList \'/I AzureCLI.msi\';Remove-Item AzureCLI.msi"']) # pylint: disable=line-too-long
else:
logger.warning(UPGRADE_MSG)
Expand Down
3 changes: 0 additions & 3 deletions src/azure-cli/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@
'resources/WindowsFunctionsStacks.json',
'resources/LinuxFunctionsStacks.json',
'resources/WebappRuntimeStacks.json'
],
'azure.cli.command_modules.util': [
'upgrade.ps1'
]
},
cmdclass=cmdclass
Expand Down

0 comments on commit fa07120

Please sign in to comment.