diff options
author | Ben Howard <ben.howard@ubuntu.com> | 2015-12-07 16:48:51 -0700 |
---|---|---|
committer | usd-importer <ubuntu-server@lists.ubuntu.com> | 2015-12-08 16:10:11 +0000 |
commit | 542c7a834728ad35d7f5f98cacdf78d86721656f (patch) | |
tree | 6850cbc7ce3dec800c1b50f23da6b76077198159 /azurelinuxagent/utils/shellutil.py | |
parent | f6e3f158c2fb9021b37654ea20839ec7a4308d52 (diff) | |
parent | f4e6aca60e419eafbdf11bdd631d35cf785735ae (diff) | |
download | vyos-walinuxagent-542c7a834728ad35d7f5f98cacdf78d86721656f.tar.gz vyos-walinuxagent-542c7a834728ad35d7f5f98cacdf78d86721656f.zip |
Import patches-applied version 2.1.2-0ubuntu1 to applied/ubuntu/xenial-proposed
Imported using git-ubuntu import.
Changelog parent: f6e3f158c2fb9021b37654ea20839ec7a4308d52
Unapplied parent: f4e6aca60e419eafbdf11bdd631d35cf785735ae
New changelog entries:
* New upstream release (LP: #1523715):
- Bug fixes for Ubuntu 15.10 on Azure
- Enablement for Azure Stack
- Dropped patch for systemd job as upstream now includes it.
Diffstat (limited to 'azurelinuxagent/utils/shellutil.py')
-rw-r--r-- | azurelinuxagent/utils/shellutil.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/azurelinuxagent/utils/shellutil.py b/azurelinuxagent/utils/shellutil.py index f4305d9..372c78a 100644 --- a/azurelinuxagent/utils/shellutil.py +++ b/azurelinuxagent/utils/shellutil.py @@ -1,4 +1,4 @@ -# Windows Azure Linux Agent +# Microsoft Azure Linux Agent # # Copyright 2014 Microsoft Corporation # @@ -65,21 +65,25 @@ def run(cmd, chk_err=True): retcode,out=run_get_output(cmd,chk_err) return retcode -def run_get_output(cmd, chk_err=True): +def run_get_output(cmd, chk_err=True, log_cmd=True): """ Wrapper for subprocess.check_output. Execute 'cmd'. Returns return code and STDOUT, trapping expected exceptions. Reports exceptions to Error if chk_err parameter is True """ - logger.verb("run cmd '{0}'", cmd) + if log_cmd: + logger.verb(u"run cmd '{0}'", cmd) try: output=subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True) + output = text(output, encoding='utf-8', errors="backslashreplace") except subprocess.CalledProcessError as e : - if chk_err : - logger.error("run cmd '{0}' failed", e.cmd) - logger.error("Error Code:{0}", e.returncode) - logger.error("Result:{0}", e.output[:-1].decode('latin-1')) - return e.returncode, e.output.decode('latin-1') - return 0, text(output, encoding="utf-8") + output = text(e.output, encoding='utf-8', errors="backslashreplace") + if chk_err: + if log_cmd: + logger.error(u"run cmd '{0}' failed", e.cmd) + logger.error(u"Error Code:{0}", e.returncode) + logger.error(u"Result:{0}", output) + return e.returncode, output + return 0, output #End shell command util functions |