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
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ WORKDIR /
RUN rm -rf ./azure-cli && \
dos2unix /root/.bashrc /usr/local/bin/az

ENV AZ_INSTALLER=DOCKER
CMD bash
1 change: 1 addition & 0 deletions build_scripts/windows/scripts/az.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
::

@IF EXIST "%~dp0\..\python.exe" (
SET AZ_INSTALLER=MSI
"%~dp0\..\python.exe" -IBm azure.cli %*
) ELSE (
echo Failed to load python executable.
Expand Down
2 changes: 1 addition & 1 deletion scripts/release/debian/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ override_dh_install:
${TAB}mkdir -p debian/azure-cli/opt/az
${TAB}cp -a python_env/* debian/azure-cli/opt/az
${TAB}mkdir -p debian/azure-cli/usr/bin/
${TAB}echo "\043!/usr/bin/env bash\n/opt/az/bin/python3 -Im azure.cli \"\044\100\"" > debian/azure-cli/usr/bin/az
${TAB}echo "\043!/usr/bin/env bash\nAZ_INSTALLER=DEB /opt/az/bin/python3 -Im azure.cli \"\044\100\"" > debian/azure-cli/usr/bin/az
${TAB}chmod 0755 debian/azure-cli/usr/bin/az
${TAB}mkdir -p debian/azure-cli/etc/bash_completion.d/
${TAB}cat ${completion_script} > debian/azure-cli/etc/bash_completion.d/azure-cli
Expand Down
2 changes: 1 addition & 1 deletion scripts/release/homebrew/docker/formula_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class AzureCli < Formula

(bin/"az").write <<~EOS
#!/usr/bin/env bash
#{libexec}/bin/python -m azure.cli \"$@\"
AZ_INSTALLER=HOMEBREW #{libexec}/bin/python -m azure.cli \"$@\"
EOS

bash_completion.install "az.completion" => "az"
Expand Down
2 changes: 1 addition & 1 deletion scripts/release/rpm/azure-cli.spec
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ for d in %{buildroot}%{cli_lib_dir}/bin/*; do perl -p -i -e "s#%{buildroot}##g"
# Create executable
mkdir -p %{buildroot}%{_bindir}
python_version=$(ls %{buildroot}%{cli_lib_dir}/lib/ | head -n 1)
printf "#!/usr/bin/env bash\nPYTHONPATH=%{cli_lib_dir}/lib/${python_version}/site-packages /usr/bin/%{python_cmd} -sm azure.cli \"\$@\"" > %{buildroot}%{_bindir}/az
printf "#!/usr/bin/env bash\nAZ_INSTALLER=RPM PYTHONPATH=%{cli_lib_dir}/lib/${python_version}/site-packages /usr/bin/%{python_cmd} -sm azure.cli \"\$@\"" > %{buildroot}%{_bindir}/az
rm %{buildroot}%{cli_lib_dir}/bin/python* %{buildroot}%{cli_lib_dir}/bin/pip*

# Set up tab completion
Expand Down
1 change: 1 addition & 0 deletions src/azure-cli-core/azure/cli/core/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def _get_azure_cli_properties(self):
set_custom_properties(result, 'Feedback', self.feedback)
set_custom_properties(result, 'ExtensionManagementDetail', self.extension_management_detail)
set_custom_properties(result, 'Mode', self.mode)
set_custom_properties(result, 'Installer', os.getenv('AZ_INSTALLER'))

return result

Expand Down
4 changes: 4 additions & 0 deletions src/azure-cli-core/azure/cli/core/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ def test_configured_default_setter(self):

@mock.patch('azure.cli.core.__version__', '7.8.9')
def test_get_az_user_agent(self):
with mock.patch.dict('os.environ', {'AZ_INSTALLER': 'PIP'}):
actual = get_az_user_agent()
self.assertEqual(actual, 'AZURECLI/7.8.9 (PIP)')

actual = get_az_user_agent()
self.assertEqual(actual, 'AZURECLI/7.8.9')

Expand Down
5 changes: 5 additions & 0 deletions src/azure-cli-core/azure/cli/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,11 @@ def get_az_user_agent():

agents = ["AZURECLI/{}".format(core_version)]

_ENV_AZ_INSTALLER = 'AZ_INSTALLER'
import os
if _ENV_AZ_INSTALLER in os.environ:
agents.append('({})'.format(os.environ[_ENV_AZ_INSTALLER]))

# msrest already has this
# https://github.com/Azure/msrest-for-python/blob/4cc8bc84e96036f03b34716466230fb257e27b36/msrest/pipeline/universal.py#L70
# if ENV_ADDITIONAL_USER_AGENT in os.environ:
Expand Down
5 changes: 4 additions & 1 deletion src/azure-cli/az
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ else:
os.environ.get('PYTHONPATH'),
])

os.execl(sys.executable, sys.executable , '-m', 'azure.cli', *sys.argv[1:])
if os.environ.get('AZ_INSTALLER') is None:
os.environ['AZ_INSTALLER'] = 'PIP'

os.execl(sys.executable, sys.executable, '-m', 'azure.cli', *sys.argv[1:])
1 change: 1 addition & 0 deletions src/azure-cli/az.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
setlocal

SET PYTHONPATH=%~dp0\src;%PYTHONPATH%
SET AZ_INSTALLER=PIP

IF EXIST "%~dp0\python.exe" (
"%~dp0\python.exe" -m azure.cli %*
Expand Down
2 changes: 2 additions & 0 deletions src/azure-cli/azure/cli/command_modules/feedback/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
```
{platform}
{python_info}
{installer}

{cli_version}
```
Expand Down Expand Up @@ -514,6 +515,7 @@ def _build_issue_info_tup(command_log_file=None):
format_dict["python_info"] = "Python {}".format(platform.python_version())
format_dict["platform"] = "{}".format(platform.platform())
format_dict["auto_gen_comment"] = _AUTO_GEN_COMMENT
format_dict["installer"] = "Installer: {}".format(os.getenv('AZ_INSTALLER') or '')

pretty_url_name = _get_extension_repo_url(ext_name) if is_ext else _CLI_ISSUES_URL

Expand Down