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 = ["sudo"]
sudo_cmd.extend(cmd) sudo_cmd.extend(cmd)
logger.info("Calling [%s]" % " ".join(sudo_cmd)) logger.info("Calling [%s]" % " ".join(sudo_cmd))
subp = subprocess.Popen(sudo_cmd) # note we supress output, as it is captured
rval = subp.wait() try:
if rval != 0: subprocess.check_output(sudo_cmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
logger.error("Calling [%s] failed with [%s]" % logger.error("Calling [%s] failed with [%s]" %
(" ".join(sudo_cmd), rval)) (e.cmd, e.returncode))
logger.error(e.output)
logger.error("Trying to continue") logger.error("Trying to continue")
def _all_part_devices_exist(self, expected_part_devices): def _all_part_devices_exist(self, expected_part_devices):