summaryrefslogtreecommitdiffstats
path: root/lib/bb/fetch2
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2012-05-20 20:36:06 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-05-23 11:29:37 +0100
commit8d6700255a6d4dda403c89b171a6d4a1883e5aae (patch)
treed150ebc7eda3bf29e54f937d1b95d199bdddce84 /lib/bb/fetch2
parentf5b3bf115dc1ffbfb241a49cec0fc3654cb71021 (diff)
downloadbitbake-8d6700255a6d4dda403c89b171a6d4a1883e5aae.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] Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/fetch2')
-rw-r--r--lib/bb/fetch2/perforce.py11
-rw-r--r--lib/bb/fetch2/svk.py4
2 files changed, 8 insertions, 7 deletions
diff --git a/lib/bb/fetch2/perforce.py b/lib/bb/fetch2/perforce.py
index 6abf15d65..df3a3a36d 100644
--- a/lib/bb/fetch2/perforce.py
+++ b/lib/bb/fetch2/perforce.py
@@ -91,8 +91,8 @@ class Perforce(FetchMethod):
p4cmd = data.getVar('FETCHCOMMAND_p4', d, True)
logger.debug(1, "Running %s%s changes -m 1 %s", p4cmd, p4opt, depot)
- p4file = os.popen("%s%s changes -m 1 %s" % (p4cmd, p4opt, depot))
- cset = p4file.readline().strip()
+ p4file, errors = bb.process.run("%s%s changes -m 1 %s" % (p4cmd, p4opt, depot))
+ cset = p4file.strip()
logger.debug(1, "READ %s", cset)
if not cset:
return -1
@@ -155,8 +155,8 @@ class Perforce(FetchMethod):
logger.debug(2, "Fetch: creating temporary directory")
bb.utils.mkdirhier(data.expand('${WORKDIR}', localdata))
data.setVar('TMPBASE', data.expand('${WORKDIR}/oep4.XXXXXX', localdata), localdata)
- tmppipe = os.popen(data.getVar('MKTEMPDIRCMD', localdata, True) or "false")
- tmpfile = tmppipe.readline().strip()
+ tmpfile, errors = bb.process.run(data.getVar('MKTEMPDIRCMD', localdata, True) or "false")
+ tmpfile = tmpfile.strip()
if not tmpfile:
raise FetchError("Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.", loc)
@@ -169,7 +169,8 @@ class Perforce(FetchMethod):
os.chdir(tmpfile)
logger.info("Fetch " + loc)
logger.info("%s%s files %s", p4cmd, p4opt, depot)
- p4file = os.popen("%s%s files %s" % (p4cmd, p4opt, depot))
+ p4file, errors = bb.process.run("%s%s files %s" % (p4cmd, p4opt, depot))
+ p4file = p4file.strip()
if not p4file:
raise FetchError("Fetch: unable to get the P4 files from %s" % depot, loc)
diff --git a/lib/bb/fetch2/svk.py b/lib/bb/fetch2/svk.py
index 9d34abf3d..ee3823f84 100644
--- a/lib/bb/fetch2/svk.py
+++ b/lib/bb/fetch2/svk.py
@@ -77,8 +77,8 @@ class Svk(FetchMethod):
logger.debug(2, "Fetch: creating temporary directory")
bb.utils.mkdirhier(data.expand('${WORKDIR}', localdata))
data.setVar('TMPBASE', data.expand('${WORKDIR}/oesvk.XXXXXX', localdata), localdata)
- tmppipe = os.popen(data.getVar('MKTEMPDIRCMD', localdata, True) or "false")
- tmpfile = tmppipe.readline().strip()
+ tmpfile, errors = bb.process.run(data.getVar('MKTEMPDIRCMD', localdata, True) or "false")
+ tmpfile = tmpfile.strip()
if not tmpfile:
logger.error()
raise FetchError("Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.", loc)