Skip to content

Commit

Permalink
wala: fix error on get python version.
Browse files Browse the repository at this point in the history
  • Loading branch information
squirrelsc committed Mar 5, 2022
1 parent a107986 commit 8ffac56
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lisa/sut_orchestrator/azure/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def get_distro_version(self) -> str:
if self._distro_version is not None:
return self._distro_version

python3_exists = self.command_exists(command="python3")
python3_exists, use_sudo = self.command_exists(command="python3")
self._log.debug(f"python3 exists: {python3_exists}, use sudo: {use_sudo}")
if python3_exists:
python_cmd = "python3"
else:
Expand All @@ -116,15 +117,17 @@ def get_distro_version(self) -> str:
# Try to use waagent code to detect
result = self.node.execute(
f'{python_cmd} -c "from azurelinuxagent.common.version import get_distro;'
"print('-'.join(get_distro()[0:3]))\""
"print('-'.join(get_distro()[0:3]))\"",
sudo=use_sudo,
)
if result.exit_code == 0:
distro_version = result.stdout
else:
# try to compat with old waagent versions
result = self.node.execute(
f'{python_cmd} -c "import platform;'
"print('-'.join(platform.linux_distribution(0)))\""
"print('-'.join(platform.linux_distribution(0)))\"",
sudo=use_sudo,
)
if result.exit_code == 0:
distro_version = result.stdout.strip('"').strip(" ").lower()
Expand Down

0 comments on commit 8ffac56

Please sign in to comment.