diff options
author | Ćukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com> | 2018-02-05 17:25:14 +0100 |
---|---|---|
committer | usd-importer <ubuntu-server@lists.ubuntu.com> | 2018-02-05 19:15:55 +0000 |
commit | bdfe3a4fa9bd487ec5f40e829742e127476d2c8a (patch) | |
tree | 947ecb04d5e2737883803034ab9885ddab70b816 /azurelinuxagent/common/utils/shellutil.py | |
parent | 6aaeb3237653102b5a376986f0ea73327a7a4379 (diff) | |
download | vyos-walinuxagent-bdfe3a4fa9bd487ec5f40e829742e127476d2c8a.tar.gz vyos-walinuxagent-bdfe3a4fa9bd487ec5f40e829742e127476d2c8a.zip |
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.
Diffstat (limited to 'azurelinuxagent/common/utils/shellutil.py')
-rw-r--r-- | azurelinuxagent/common/utils/shellutil.py | 26 |
1 files changed, 16 insertions, 10 deletions
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 |