From 5996b2b58e36864edc077326a942795ca12f48da Mon Sep 17 00:00:00 2001 From: Robert Yang Date: Tue, 29 May 2012 22:53:08 +0800 Subject: 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 Signed-off-by: Richard Purdie --- meta/classes/distrodata.bbclass | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'meta/classes/distrodata.bbclass') diff --git a/meta/classes/distrodata.bbclass b/meta/classes/distrodata.bbclass index df6d300666..7f9c83e7c7 100644 --- a/meta/classes/distrodata.bbclass +++ b/meta/classes/distrodata.bbclass @@ -564,10 +564,10 @@ python do_checkpkg() { gitproto = parm['protocol'] else: gitproto = "git" - gitcmd = "git ls-remote %s://%s%s%s *tag* 2>&1" % (gitproto, gituser, host, path) - gitcmd2 = "git ls-remote %s://%s%s%s HEAD 2>&1" % (gitproto, gituser, host, path) - tmp = os.popen(gitcmd).read() - tmp2 = os.popen(gitcmd2).read() + gitcmd = "git ls-remote %s://%s%s%s *tag*" % (gitproto, gituser, host, path) + gitcmd2 = "git ls-remote %s://%s%s%s HEAD" % (gitproto, gituser, host, path) + tmp = bb.process.run(gitcmd)[0] + tmp2 = bb.process.run(gitcmd2)[0] #This is for those repo have tag like: refs/tags/1.2.2 if tmp: tmpline = tmp.split("\n") @@ -613,9 +613,9 @@ python do_checkpkg() { if 'rev' in parm: pcurver = parm['rev'] - svncmd = "svn info %s %s://%s%s/%s/ 2>&1" % (" ".join(options), svnproto, host, path, parm["module"]) + svncmd = "svn info %s %s://%s%s/%s/" % (" ".join(options), svnproto, host, path, parm["module"]) print svncmd - svninfo = os.popen(svncmd).read() + svninfo = bb.process.run(svncmd)[0] for line in svninfo.split("\n"): if re.search("^Last Changed Rev:", line): pupver = line.split(" ")[-1] -- cgit v1.2.3-54-g00ecf