[gnome-continuous-yocto/gnomeostree-3.28-rocko: 2802/8267] subprocess: remove Popen in favor of check_output
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-continuous-yocto/gnomeostree-3.28-rocko: 2802/8267] subprocess: remove Popen in favor of check_output
- Date: Sat, 16 Dec 2017 23:44:28 +0000 (UTC)
commit 5d96223e312fe8276ab9684e13cb2af41536e48a
Author: Stephano Cetola <stephano cetola linux intel com>
Date: Thu Sep 29 15:50:24 2016 -0700
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>
meta/classes/buildstats.bbclass | 6 +++++-
meta/classes/spdx.bbclass | 11 +++++------
2 files changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass
index 34ecb03..8c2b7b3 100644
--- a/meta/classes/buildstats.bbclass
+++ b/meta/classes/buildstats.bbclass
@@ -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):
diff --git a/meta/classes/spdx.bbclass b/meta/classes/spdx.bbclass
index 0c92765..89394d3 100644
--- a/meta/classes/spdx.bbclass
+++ b/meta/classes/spdx.bbclass
@@ -219,14 +219,13 @@ def hash_string(data):
def run_fossology(foss_command, full_spdx):
import string, re
import subprocess
-
- p = subprocess.Popen(foss_command.split(),
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- foss_output, foss_error = p.communicate()
- if p.returncode != 0:
+
+ try:
+ foss_output = subprocess.check_output(foss_command.split(),
+ stderr=subprocess.STDOUT).decode('utf-8')
+ except subprocess.CalledProcessError as e:
return None
- foss_output = unicode(foss_output, "utf-8")
foss_output = string.replace(foss_output, '\r', '')
# Package info
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]