summaryrefslogtreecommitdiffstats
path: root/meta/classes/metadata_scm.bbclass
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2012-05-29 14:53:08 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-05-30 11:04:45 (GMT)
commit5996b2b58e36864edc077326a942795ca12f48da (patch)
tree5f67615a25685f4b0d4a8150f51932a5b478ccfa /meta/classes/metadata_scm.bbclass
parentd760fb97f52c705944a259be267e0ea8516074e3 (diff)
downloadpoky-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/metadata_scm.bbclass')
-rw-r--r--meta/classes/metadata_scm.bbclass12
1 files changed, 5 insertions, 7 deletions
diff --git a/meta/classes/metadata_scm.bbclass b/meta/classes/metadata_scm.bbclass
index 62650be..5af593a 100644
--- a/meta/classes/metadata_scm.bbclass
+++ b/meta/classes/metadata_scm.bbclass
@@ -60,18 +60,16 @@ def base_get_metadata_svn_revision(path, d):
60 return revision 60 return revision
61 61
62def base_get_metadata_git_branch(path, d): 62def base_get_metadata_git_branch(path, d):
63 branch = os.popen('cd %s; git branch 2>&1 | grep "^* " | tr -d "* "' % path).read() 63 branch = bb.process.run('cd %s; git branch | grep "^* " | tr -d "* "' % path)[0]
64 64
65 if len(branch) != 0: 65 if len(branch) != 0:
66 return branch 66 return branch
67 return "<unknown>" 67 return "<unknown>"
68 68
69def base_get_metadata_git_revision(path, d): 69def base_get_metadata_git_revision(path, d):
70 f = os.popen("cd %s; git log -n 1 --pretty=oneline -- 2>&1" % path) 70 rev = bb.process.run("cd %s; git log -n 1 --pretty=oneline" % path)[0]
71 data = f.read() 71 if len(rev) != 0:
72 if f.close() is None: 72 rev = rev.split(" ")[0]
73 rev = data.split(" ")[0] 73 return rev
74 if len(rev) != 0:
75 return rev
76 return "<unknown>" 74 return "<unknown>"
77 75