def set_configured_jobresult(self, in_chroot): idfile = Utility.get_result_dir() + '/result-id' if not in_chroot: idfile = '/mnt/' + idfile fp = open(idfile, 'w') fp.write(self.hash) fp.close
def get_configured_jobresult(session, in_chroot): idfile = Utility.get_result_dir() + '/result-id' if not in_chroot: idfile = '/mnt/' + idfile if not os.path.isfile(idfile): return None fp = open(idfile, 'r') result_hash = fp.read().strip() fp.close() return JobResult.get_by_hash(session, result_hash)
def _run(self): assert self.result.status == TaskResult.PENDING if not self.should_run(): self.result.status = TaskResult.SKIPPED return if not self.dependencies_resolved: self.result.status = TaskResult.DEPENDENCY_ERROR return clshash = hashlib.md5(str(self.__class__)).hexdigest() outputfile = Utility.get_result_dir() + '/output_' + clshash outputfp = open(outputfile, "w") stdoutfd = os.dup(1) stderrfd = os.dup(2) os.dup2(outputfp.fileno(), 1) os.dup2(outputfp.fileno(), 2) self.result.status = TaskResult.RUNNING JobSession.object_session(self.result).commit() try: status = self.prepare() if status == None or status == TaskResult.PASSED: self.result.run_start = datetime.now() status = self.run() self.result.run_end = datetime.now() if status == None: status = TaskResult.FAILED except Exception, exc: status = TaskResult.FAILED self.result.attributes['exception'] = str(exc) self.result.attributes['stacktrace'] = traceback.format_exc() print exc
def run(self): for file in glob.glob("/var/crash/[0-9]*/*"): shutil.copy(file, Utility.get_result_dir()) return TaskResult.PASSED