summaryrefslogtreecommitdiff
path: root/azurelinuxagent/common/utils/shellutil.py
diff options
context:
space:
mode:
authorƁukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com>2018-02-05 17:25:14 +0100
committerusd-importer <ubuntu-server@lists.ubuntu.com>2018-02-05 19:15:55 +0000
commit6c9cd7e1ac55aae259d8e2f06569375e27a12f20 (patch)
tree335726f611f1ed30aef7d82ff0e2bae0a91ff44b /azurelinuxagent/common/utils/shellutil.py
parent110d301b04a64d680fc7d102424e303a8e3ca1a6 (diff)
parentd5298bbf0f5696fc948877304e86f43d477d6b71 (diff)
downloadvyos-walinuxagent-6c9cd7e1ac55aae259d8e2f06569375e27a12f20.tar.gz
vyos-walinuxagent-6c9cd7e1ac55aae259d8e2f06569375e27a12f20.zip
Import patches-applied version 2.2.21-0ubuntu1 to applied/ubuntu/bionic-proposed
Imported using git-ubuntu import. Changelog parent: 110d301b04a64d680fc7d102424e303a8e3ca1a6 Unapplied parent: d5298bbf0f5696fc948877304e86f43d477d6b71 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.py26
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