Skip to content
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

Switch to run command #2022

Merged
merged 21 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion azurelinuxagent/common/osutil/ubuntu.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def restart_if(self, ifname, retries=3, wait=5):
try:
shellutil.run_command(["ip", "link", "set", ifname, "down"])
shellutil.run_command(["ip", "link", "set", ifname, "up"])
return

except shellutil.CommandError as cmd_err:
logger.warn("failed to restart {0}: return code {1}".format(ifname, cmd_err.returncode))
if attempt < retry_limit:
Expand Down
3 changes: 3 additions & 0 deletions azurelinuxagent/common/utils/cryptutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ def decrypt_p7m(self, p7m_file, trans_prv_file, trans_cert_file, pem_file):
stdout, stderr = second_proc.communicate()

if first_proc.returncode != 0 or second_proc.returncode != 0:
stdout = ustr(stdout, encoding='utf-8', errors="backslashreplace") if stdout else ""
Copy link
Contributor

@larohra larohra Oct 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: How about making this function public and using this instead -

def _encode_command_output(output):
    return ustr(output, encoding='utf-8', errors="backslashreplace")

Its in the shellutils.py

stderr = ustr(stderr, encoding='utf-8', errors="backslashreplace") if stderr else ""

msg = """Failed to decrypt {0}
[stdout]
{1}
Expand Down
2 changes: 1 addition & 1 deletion tests/common/osutil/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_restart(self):
self.assertEqual(cmd_queue.pop(0), ["ifdown", ifname])
# We don't expect the following command to be called because 'dummy' does
# not exist.
# self.assertEqual(cmd_queue.pop(0), ["ifup", ifname])
self.assertNotEqual(cmd_queue[0] if cmd_queue else None, ["ifup", ifname])


def test_get_dvd_device_success(self):
Expand Down