def testGenerator(cls, config, logger): initialPath = os.getcwd() results = [] for test in config: logger.debug("Changing working dir to " + test["path"]) os.chdir(test["path"]) logger.info("Getting list of Generator jobs") jobList = Builder.__getGeneratorJobs(test) configOption = "" if "config" in test: configOption = " -c %s" % test["config"] for job in jobList: cmd = "%s generate.py -s %s %s" % (sys.executable, configOption, job) result = Builder.__getGeneratorResultDict(job, test["path"]) logger.info("Running job: " + cmd) (ret, out, err) = util.invokePiped(cmd) result["stopDate"] = util.getTimestamp() result["command"] = cmd result["returncode"] = ret result["stdout"] = out result["stderr"] = err results.append(result) if ret == 0: logger.info("Result: OK") else: logger.warn("Result: Error") logger.warn(err) os.chdir(initialPath) return results
def testGenerator(cls, config, logger): initialPath = os.getcwd() results = [] for test in config: logger.debug("Changing working dir to " + test["path"]) os.chdir(test["path"]) logger.info("Getting list of Generator jobs") jobList = Builder.__getGeneratorJobs(test) configOption = "" if "config" in test: configOption = " -c %s" %test["config"] for job in jobList: cmd = "%s generate.py -s %s %s" %(sys.executable, configOption, job) result = Builder.__getGeneratorResultDict(job, test["path"]) logger.info("Running job: " + cmd) (ret,out,err) = util.invokePiped(cmd) result["stopDate"] = util.getTimestamp() result["command"] = cmd result["returncode"] = ret result["stdout"] = out result["stderr"] = err results.append(result) if ret == 0: logger.info("Result: OK") else: logger.warn("Result: Error") logger.warn(err) os.chdir(initialPath) return results
def __getLintResult(self, workdir): self.log.info("Running lint in directory %s" %workdir) startdir = os.getcwd() os.chdir(workdir) ret,out,err = util.invokePiped(sys.executable + " generate.py lint") if (ret > 0): raise RuntimeError, "Lint run failed. " + err os.chdir(startdir) return out
def do(self, cmd=None): if not cmd: return os.chdir(self.path) (ret,out,err) = util.invokePiped(cmd) result = False if ret > 0: result = out + " " + err else: result = out os.chdir(self.startDir) return result
def __getGeneratorJobs(cls, test): if "jobs" in test: return test["jobs"] elif "config" in test: jobList = [] import re cmd = "%s generate.py -c %s x" %(sys.executable, test["config"]) (ret,out,err) = util.invokePiped(cmd) reg = re.compile("^ - (.+?)(?:\s|$)") strParts = out.split("\n") for part in strParts: match = reg.search(part) if match: if match.group(1): jobList.append(match.group(1)) return jobList
def buildAppWithErrorLogging(self, target, cmd, buildLog): self.log.info("Building %s: %s" %(target,cmd)) status, std, err = util.invokePiped(cmd) #@UnusedVariable if status > 0: if buildLog: self.logBuildErrors(buildLog, target, cmd, err) buildLog.close() self.buildStatus[target]["BuildError"] = "Unknown build error" """Get the last line of batbuild.py's STDERR output which contains the actual error message. """ error = util.getLastLineFromString(err) if error: self.buildStatus[target]["BuildError"] = error else: self.log.info("%s build finished without errors." %target) self.buildStatus[target]["BuildFinished"] = time.strftime(Builder.timeFormat)
def __getGeneratorJobs(cls, test): if "jobs" in test: return test["jobs"] elif "config" in test: jobList = [] import re cmd = "%s generate.py -c %s x" % (sys.executable, test["config"]) (ret, out, err) = util.invokePiped(cmd) reg = re.compile("^ - (.+?)(?:\s|$)") strParts = out.split("\n") for part in strParts: match = reg.search(part) if match: if match.group(1): jobList.append(match.group(1)) return jobList
def buildAppWithErrorLogging(self, target, cmd, buildLog): self.log.info("Building %s: %s" % (target, cmd)) status, std, err = util.invokePiped(cmd) #@UnusedVariable if status > 0: if buildLog: self.logBuildErrors(buildLog, target, cmd, err) buildLog.close() self.buildStatus[target]["BuildError"] = "Unknown build error" """Get the last line of batbuild.py's STDERR output which contains the actual error message. """ error = util.getLastLineFromString(err) if error: self.buildStatus[target]["BuildError"] = error else: self.log.info("%s build finished without errors." % target) self.buildStatus[target]["BuildFinished"] = time.strftime( Builder.timeFormat)
def testGenerator(cls, config): initialPath = os.getcwd() results = [] for test in config: os.chdir(test["path"]) jobList = Builder.__getGeneratorJobs(test) configOption = "" if "config" in test: configOption = " -c %s" %test["config"] for job in jobList: cmd = "python generate.py -s %s %s" %(configOption, job) result = Builder.__getGeneratorResultDict(job, test["path"]) (ret,out,err) = util.invokePiped(cmd) result["stopDate"] = util.getTimestamp() result["command"] = cmd result["returncode"] = ret result["stdout"] = out result["stderr"] = err results.append(result) os.chdir(initialPath) return results