diff options
author | Robert Yang <liezhi.yang@windriver.com> | 2012-05-20 20:36:06 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-05-23 11:35:11 +0100 |
commit | 094742bed2fc01d55f572da946fcfa7a48521401 (patch) | |
tree | b85f26efa2cfd5a409681bcfc3a8758d085274fc /bitbake/lib/bb/fetch2/svk.py | |
parent | 10a0f9ed929449543e5caab7e5f8855e0e68605b (diff) | |
download | poky-094742bed2fc01d55f572da946fcfa7a48521401.tar.gz |
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 is a bb.process.run() which will invoke the Popen to run command,
use it for simplify the code.
For the:
p4file = os.popen("%s%s files %s" % (p4cmd, p4opt, depot))
...
for file in p4file:
list = file.split()
in bitbake/lib/bb/fetch2/perforce.py, it should be an error in the past,
since it didn't use readline() to read the pipe, but directly used the
split() for the pipe. Use the bb.process.run would fix the problem since
bb.process.run will return strings.
More info:
http://docs.python.org/library/subprocess.html#subprocess-replacements
[YOCTO #2075]
(Bitbake rev: 8d6700255a6d4dda403c89b171a6d4a1883e5aae)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2/svk.py')
-rw-r--r-- | bitbake/lib/bb/fetch2/svk.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/bitbake/lib/bb/fetch2/svk.py b/bitbake/lib/bb/fetch2/svk.py index 9d34abf3da..ee3823f845 100644 --- a/bitbake/lib/bb/fetch2/svk.py +++ b/bitbake/lib/bb/fetch2/svk.py | |||
@@ -77,8 +77,8 @@ class Svk(FetchMethod): | |||
77 | logger.debug(2, "Fetch: creating temporary directory") | 77 | logger.debug(2, "Fetch: creating temporary directory") |
78 | bb.utils.mkdirhier(data.expand('${WORKDIR}', localdata)) | 78 | bb.utils.mkdirhier(data.expand('${WORKDIR}', localdata)) |
79 | data.setVar('TMPBASE', data.expand('${WORKDIR}/oesvk.XXXXXX', localdata), localdata) | 79 | data.setVar('TMPBASE', data.expand('${WORKDIR}/oesvk.XXXXXX', localdata), localdata) |
80 | tmppipe = os.popen(data.getVar('MKTEMPDIRCMD', localdata, True) or "false") | 80 | tmpfile, errors = bb.process.run(data.getVar('MKTEMPDIRCMD', localdata, True) or "false") |
81 | tmpfile = tmppipe.readline().strip() | 81 | tmpfile = tmpfile.strip() |
82 | if not tmpfile: | 82 | if not tmpfile: |
83 | logger.error() | 83 | logger.error() |
84 | raise FetchError("Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.", loc) | 84 | raise FetchError("Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.", loc) |