subprocess: remove Popen in favor of check_output

This begins moving away from the deprecated subprocess calls in an
effort to eventually move to some more global abstraction using the run
convenience method provided in python 3.5.

[ YOCTO #9342 ]

(From OE-Core rev: 0d6b7276003f1afabc6de683f663540327d52bdc)

Signed-off-by: Stephano Cetola <stephano.cetola@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Stephano Cetola
2016-09-29 15:50:24 -07:00
committed by Richard Purdie
parent 1ab3a23739
commit 5d96223e31
2 changed files with 10 additions and 7 deletions

View File

@@ -163,7 +163,11 @@ python run_buildstats () {
bs = os.path.join(bsdir, "build_stats")
with open(bs, "a") as f:
rootfs = d.getVar('IMAGE_ROOTFS', True)
rootfs_size = subprocess.Popen(["du", "-sh", rootfs], stdout=subprocess.PIPE).stdout.read()
try:
rootfs_size = subprocess.check_output(["du", "-sh", rootfs],
stderr=subprocess.STDOUT).decode('utf-8')
except subprocess.CalledProcessError as e:
bb.error("Failed to get rootfs size: %s" % e.output)
f.write("Uncompressed Rootfs size: %s" % rootfs_size)
elif isinstance(e, bb.build.TaskFailed):