summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorKang Kai <kai.kang@windriver.com>2012-06-15 10:56:11 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-06-18 13:24:57 +0100
commit21d84d2fe3ac4a73f6477bd87ef459969d0d8850 (patch)
tree831f8a7ac0a64c664d6a5eb0be4de0b566359b02 /scripts
parent7dbc26874f9e5bb9e057b32e02b099faca4aed15 (diff)
downloadpoky-21d84d2fe3ac4a73f6477bd87ef459969d0d8850.tar.gz
cleanup-workdir: replace commands with subprocess
Use modules subprocess to run command instead of module commands. (From OE-Core rev: 33f18965bbeeec47f694f2aa165e5e07eadb7ab7) Signed-off-by: Kang Kai <kai.kang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/cleanup-workdir22
1 files changed, 12 insertions, 10 deletions
diff --git a/scripts/cleanup-workdir b/scripts/cleanup-workdir
index 3739a00032..1e9c56dcf6 100755
--- a/scripts/cleanup-workdir
+++ b/scripts/cleanup-workdir
@@ -19,7 +19,7 @@ import os
19import sys 19import sys
20import optparse 20import optparse
21import re 21import re
22import commands 22import subprocess
23import shutil 23import shutil
24 24
25pkg_cur_dirs = [] 25pkg_cur_dirs = []
@@ -39,6 +39,14 @@ def parse_version(verstr):
39 else: 39 else:
40 return epoch + '_' + elems[1] 40 return epoch + '_' + elems[1]
41 41
42def run_command(cmd):
43 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
44 output = pipe.communicate()[0]
45 if pipe.returncode != 0:
46 print "Execute command '%s' failed." % cmd
47 sys.exit(1)
48 return output
49
42def main(): 50def main():
43 global parser 51 global parser
44 parser = optparse.OptionParser( 52 parser = optparse.OptionParser(
@@ -49,7 +57,7 @@ This script must be ran under BUILDDIR after source file \"oe-init-build-env\"."
49 57
50 options, args = parser.parse_args(sys.argv) 58 options, args = parser.parse_args(sys.argv)
51 59
52 builddir = commands.getoutput('echo $BUILDDIR') 60 builddir = run_command('echo $BUILDDIR').strip()
53 if len(builddir) == 0: 61 if len(builddir) == 0:
54 err_quit("Please source file \"oe-init-build-env\" first.\n") 62 err_quit("Please source file \"oe-init-build-env\" first.\n")
55 63
@@ -58,10 +66,7 @@ This script must be ran under BUILDDIR after source file \"oe-init-build-env\"."
58 66
59 print 'Updating bitbake caches...' 67 print 'Updating bitbake caches...'
60 cmd = "bitbake -s" 68 cmd = "bitbake -s"
61 (ret, output) = commands.getstatusoutput(cmd) 69 output = run_command(cmd)
62 if ret != 0:
63 print "Execute 'bitbake -s' failed. Can't get packages' versions."
64 return 1
65 70
66 output = output.split('\n') 71 output = output.split('\n')
67 index = 0 72 index = 0
@@ -83,10 +88,7 @@ This script must be ran under BUILDDIR after source file \"oe-init-build-env\"."
83 pkg_cur_dirs.append(elems[0] + '-' + version) 88 pkg_cur_dirs.append(elems[0] + '-' + version)
84 89
85 cmd = "bitbake -e | grep ^TMPDIR" 90 cmd = "bitbake -e | grep ^TMPDIR"
86 (ret, output) = commands.getstatusoutput(cmd) 91 output = run_command(cmd)
87 if ret != 0:
88 print "Execute 'bitbke -e' failed. Can't get TMPDIR."
89 return 1
90 92
91 tmpdir = output.split('"')[1] 93 tmpdir = output.split('"')[1]
92 workdir = os.path.join(tmpdir, 'work') 94 workdir = os.path.join(tmpdir, 'work')