From bdfe3a4fa9bd487ec5f40e829742e127476d2c8a Mon Sep 17 00:00:00 2001 From: Ɓukasz 'sil2100' Zemczak Date: Mon, 5 Feb 2018 17:25:14 +0100 Subject: Import patches-unapplied version 2.2.21-0ubuntu1 to ubuntu/bionic-proposed Imported using git-ubuntu import. Changelog parent: 6aaeb3237653102b5a376986f0ea73327a7a4379 New changelog entries: * New upstream release (LP: #1746628). * debian/patches/disable_import_test.patch: refreshed patch. --- azurelinuxagent/common/utils/shellutil.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'azurelinuxagent/common/utils/shellutil.py') diff --git a/azurelinuxagent/common/utils/shellutil.py b/azurelinuxagent/common/utils/shellutil.py index fff6aa8..7b8e0c9 100644 --- a/azurelinuxagent/common/utils/shellutil.py +++ b/azurelinuxagent/common/utils/shellutil.py @@ -84,16 +84,22 @@ def run_get_output(cmd, chk_err=True, log_cmd=True): output = ustr(output, encoding='utf-8', errors="backslashreplace") - except subprocess.CalledProcessError as e: - output = ustr(e.output, - encoding='utf-8', - errors="backslashreplace") - if chk_err: - if log_cmd: - logger.error(u"Command: '{0}'", e.cmd) - logger.error(u"Return code: {0}", e.returncode) - logger.error(u"Result: {0}", output) - return e.returncode, output + except Exception as e: + if type(e) is subprocess.CalledProcessError: + output = ustr(e.output, + encoding='utf-8', + errors="backslashreplace") + if chk_err: + if log_cmd: + logger.error(u"Command: '{0}'", e.cmd) + logger.error(u"Return code: {0}", e.returncode) + logger.error(u"Result: {0}", output) + return e.returncode, output + else: + logger.error( + u"'{0}' raised unexpected exception: '{1}'".format( + cmd, ustr(e))) + return -1, ustr(e) return 0, output -- cgit v1.2.3