From 5996b2b58e36864edc077326a942795ca12f48da Mon Sep 17 00:00:00 2001 From: Robert Yang Date: Tue, 29 May 2012 22:53:08 +0800 Subject: meta: replace os.popen with subprocess.Popen Replace os.popen with subprocess.Popen since the older function would fail (more or less) silently if the executed program cannot be found There are both bb.process.run() and bb.process.Popen() which wraps the subprocess module, use it for simplifying the code. Note: We don't need the "2>/dev/null" or "2>&1" since bb.process.run() can handle it, it will raise exception when error occurs, we should handle the exception ourselves if we want to ignore the error. More info: http://docs.python.org/library/subprocess.html#subprocess-replacements [YOCTO #2454] (From OE-Core rev: e83d8e58a6b107eea87df0ec233a1bc932b2c6ea) Signed-off-by: Robert Yang Signed-off-by: Richard Purdie --- meta/classes/icecc.bbclass | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'meta/classes/icecc.bbclass') diff --git a/meta/classes/icecc.bbclass b/meta/classes/icecc.bbclass index ae74050f6b..64a182e523 100644 --- a/meta/classes/icecc.bbclass +++ b/meta/classes/icecc.bbclass @@ -54,7 +54,7 @@ def create_path(compilers, bb, d): staging += "-kernel" #check if the icecc path is set by the user - icecc = d.getVar('ICECC_PATH') or os.popen("which icecc").read()[:-1] + icecc = d.getVar('ICECC_PATH') or bb.process.run("which icecc")[0][:-1] # Create the dir if necessary try: @@ -151,9 +151,9 @@ def icc_path(bb,d): def icc_get_tool(bb, d, tool): if icc_is_native(bb, d): - return os.popen("which %s" % tool).read()[:-1] + return bb.process.run("which %s" % tool)[0][:-1] elif icc_is_kernel(bb, d): - return os.popen("which %s" % get_cross_kernel_cc(bb, d)).read()[:-1] + return bb.process.run("which %s" % get_cross_kernel_cc(bb, d))[0][:-1] else: ice_dir = d.expand('${STAGING_BINDIR_TOOLCHAIN}') target_sys = d.expand('${TARGET_SYS}') -- cgit v1.2.3-54-g00ecf