summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/combo-layer18
1 files changed, 11 insertions, 7 deletions
diff --git a/scripts/combo-layer b/scripts/combo-layer
index 62f2cf8fa3..3ee9eb203d 100755
--- a/scripts/combo-layer
+++ b/scripts/combo-layer
@@ -152,23 +152,27 @@ class Configuration(object):
152 logger.error("ERROR: patchutils package is missing, please install it (e.g. # apt-get install patchutils)") 152 logger.error("ERROR: patchutils package is missing, please install it (e.g. # apt-get install patchutils)")
153 sys.exit(1) 153 sys.exit(1)
154 154
155def runcmd(cmd,destdir=None,printerr=True): 155def runcmd(cmd,destdir=None,printerr=True,out=None):
156 """ 156 """
157 execute command, raise CalledProcessError if fail 157 execute command, raise CalledProcessError if fail
158 return output if succeed 158 return output if succeed
159 """ 159 """
160 logger.debug("run cmd '%s' in %s" % (cmd, os.getcwd() if destdir is None else destdir)) 160 logger.debug("run cmd '%s' in %s" % (cmd, os.getcwd() if destdir is None else destdir))
161 out = os.tmpfile() 161 if not out:
162 out = os.tmpfile()
163 err = out
164 else:
165 err = os.tmpfile()
162 try: 166 try:
163 subprocess.check_call(cmd, stdout=out, stderr=out, cwd=destdir, shell=True) 167 subprocess.check_call(cmd, stdout=out, stderr=err, cwd=destdir, shell=isinstance(cmd, str))
164 except subprocess.CalledProcessError,e: 168 except subprocess.CalledProcessError,e:
165 out.seek(0) 169 err.seek(0)
166 if printerr: 170 if printerr:
167 logger.error("%s" % out.read()) 171 logger.error("%s" % err.read())
168 raise e 172 raise e
169 173
170 out.seek(0) 174 err.seek(0)
171 output = out.read() 175 output = err.read()
172 logger.debug("output: %s" % output ) 176 logger.debug("output: %s" % output )
173 return output 177 return output
174 178