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/debian.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/debian.bbclass')
-rw-r--r-- | meta/classes/debian.bbclass | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/meta/classes/debian.bbclass b/meta/classes/debian.bbclass index 3637e2ebe7..963d11c129 100644 --- a/meta/classes/debian.bbclass +++ b/meta/classes/debian.bbclass | |||
@@ -60,10 +60,14 @@ python debian_package_name_hook () { | |||
60 | for f in files: | 60 | for f in files: |
61 | if so_re.match(f): | 61 | if so_re.match(f): |
62 | fp = os.path.join(root, f) | 62 | fp = os.path.join(root, f) |
63 | cmd = (d.getVar('BUILD_PREFIX', True) or "") + "objdump -p " + fp + " 2>/dev/null" | 63 | cmd = (d.getVar('BUILD_PREFIX', True) or "") + "objdump -p " + fp |
64 | fd = os.popen(cmd) | 64 | try: |
65 | lines = fd.readlines() | 65 | lines = "" |
66 | fd.close() | 66 | lines = bb.process.run(cmd)[0] |
67 | # Some ".so" maybe ascii text, e.g: /usr/lib64/libpthread.so, | ||
68 | # ingore those errors. | ||
69 | except Exception: | ||
70 | sys.exc_clear() | ||
67 | for l in lines: | 71 | for l in lines: |
68 | m = re.match("\s+SONAME\s+([^\s]*)", l) | 72 | m = re.match("\s+SONAME\s+([^\s]*)", l) |
69 | if m and not m.group(1) in sonames: | 73 | if m and not m.group(1) in sonames: |