Capture output in _exec_sudo

The stdout of the script is captured, so anything coming out from
these commands needs to be captured.  Move to check_process and show
the output as part of an error log in failure case.

Change-Id: I1150375cdc479d4f19b8ddeb49a824ab16fdf831
This commit is contained in:
Ian Wienand 2017-03-23 09:31:37 +11:00
parent f1d53f2e31
commit a8f2eaded8

View File

@ -155,11 +155,13 @@ class Partitioning(object):
sudo_cmd = ["sudo"]
sudo_cmd.extend(cmd)
logger.info("Calling [%s]" % " ".join(sudo_cmd))
subp = subprocess.Popen(sudo_cmd)
rval = subp.wait()
if rval != 0:
# note we supress output, as it is captured
try:
subprocess.check_output(sudo_cmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
logger.error("Calling [%s] failed with [%s]" %
(" ".join(sudo_cmd), rval))
(e.cmd, e.returncode))
logger.error(e.output)
logger.error("Trying to continue")
def _all_part_devices_exist(self, expected_part_devices):