diff options
author | Robert Yang <liezhi.yang@windriver.com> | 2012-05-29 22:53:08 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-05-30 12:04:45 +0100 |
commit | 5996b2b58e36864edc077326a942795ca12f48da (patch) | |
tree | 5f67615a25685f4b0d4a8150f51932a5b478ccfa /meta/classes/icecc.bbclass | |
parent | d760fb97f52c705944a259be267e0ea8516074e3 (diff) | |
download | poky-5996b2b58e36864edc077326a942795ca12f48da.tar.gz |
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 <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/icecc.bbclass')
-rw-r--r-- | meta/classes/icecc.bbclass | 6 |
1 files changed, 3 insertions, 3 deletions
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): | |||
54 | staging += "-kernel" | 54 | staging += "-kernel" |
55 | 55 | ||
56 | #check if the icecc path is set by the user | 56 | #check if the icecc path is set by the user |
57 | icecc = d.getVar('ICECC_PATH') or os.popen("which icecc").read()[:-1] | 57 | icecc = d.getVar('ICECC_PATH') or bb.process.run("which icecc")[0][:-1] |
58 | 58 | ||
59 | # Create the dir if necessary | 59 | # Create the dir if necessary |
60 | try: | 60 | try: |
@@ -151,9 +151,9 @@ def icc_path(bb,d): | |||
151 | 151 | ||
152 | def icc_get_tool(bb, d, tool): | 152 | def icc_get_tool(bb, d, tool): |
153 | if icc_is_native(bb, d): | 153 | if icc_is_native(bb, d): |
154 | return os.popen("which %s" % tool).read()[:-1] | 154 | return bb.process.run("which %s" % tool)[0][:-1] |
155 | elif icc_is_kernel(bb, d): | 155 | elif icc_is_kernel(bb, d): |
156 | return os.popen("which %s" % get_cross_kernel_cc(bb, d)).read()[:-1] | 156 | return bb.process.run("which %s" % get_cross_kernel_cc(bb, d))[0][:-1] |
157 | else: | 157 | else: |
158 | ice_dir = d.expand('${STAGING_BINDIR_TOOLCHAIN}') | 158 | ice_dir = d.expand('${STAGING_BINDIR_TOOLCHAIN}') |
159 | target_sys = d.expand('${TARGET_SYS}') | 159 | target_sys = d.expand('${TARGET_SYS}') |