def _execute(self, db: Database): logging.info("Execute {!r} in directory {!r}".format( self.cmd, self.working_dir)) proc = subprocess.Popen(["/bin/sh", "-c", self.cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, cwd=abspath(self.working_dir)) out, err = proc.communicate() ret_code = proc.wait() if self.send_mail: def format_out(out): return out.replace("\n", "\n\t") content = """ Command: {cmd} Return code: {ret} Standard out: {out} Standard Error: {err} """.format(cmd=self.cmd, ret=ret_code, out=format_out(out), err=format_out(err)) send_mail(self.mail_address, self.mail_header, content)
def store_and_teardown(self): """ Teardown everything, store the result file, print a short report and send an email if configured to do so. """ if Settings().has_log_level("info") and self.show_report: self.print_report() self.teardown() self.store() if len(self.stats_helper.valid_runs()) > 0 \ and all(x.benchmarks() > 0 for x in self.stats_helper.valid_runs()): report = "" if not in_standalone_mode: report = ReporterRegistry.get_for_name("console", self.stats_helper)\ .report(with_tester_results=False, to_string = True) self.stats_helper.valid_runs()[0].description() subject = "Finished " + join_strs([repr(run.description()) for run in self.stats_helper.valid_runs()]) send_mail(Settings()["run/send_mail"], subject, report, [Settings()["run/out"]]) if len(self.erroneous_run_blocks) > 0: descrs = [] msgs = [] for (i, result) in self.erroneous_run_blocks: descr = repr(RunData(attributes=self.runs[i]["attributes"]).description()) descrs.append(descr) msg = descr + ":\n\t" + "\n\t".join(str(result.error).split("\n")) msgs.append(msg) subject = "Errors while benchmarking " + join_strs(descrs) send_mail(Settings()["run/send_mail"], subject, "\n\n".join(msgs), [Settings()["run/in"] + ".erroneous.yaml"])
def store_and_teardown(self): """ Teardown everything, store the result file, print a short report and send an email if configured to do so. """ self.teardown() if not self.pool.run_driver.store_files: return self.store() if len(self.stats_helper.valid_runs()) > 0 \ and all(x.benchmarks() > 0 for x in self.stats_helper.valid_runs()): report = "" if not in_standalone_mode: report = ReporterRegistry.get_for_name("console", self.stats_helper)\ .report(with_tester_results=False, to_string=True) subject = "Finished " + join_strs([repr(run.description()) for run in self.stats_helper.valid_runs()]) send_mail(Settings()["run/send_mail"], subject, report, [Settings()["run/out"]]) if self.recorded_error(): descrs = [] msgs = [] for (i, result) in self.erroneous_run_blocks: descr = self.run_blocks[i].description() descrs.append(descr) msg = descr + ":\n\t" + "\n\t".join(str(result.error).split("\n")) msgs.append(msg) subject = "Errors while benchmarking " + join_strs(descrs) send_mail(Settings()["run/send_mail"], subject, "\n\n".join(msgs), [Settings()["run/in"] + ".erroneous.yaml"])
def _fail(self, message: str): """ Fail with the given error message and send an error mail if configured to do so :param message: given error message """ logging.error(message) send_mail(Settings()["package/send_mail"], "Error", message) exit(1)
def _execute(self, db: Database): logging.info("Execute {!r} in directory {!r}".format(self.cmd, self.working_dir)) proc = subprocess.Popen(["/bin/sh", "-c", self.cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, cwd=abspath(self.working_dir)) out, err = proc.communicate() ret_code = proc.wait() if self.send_mail: def format_out(out): return out.replace("\n", "\n\t") content = """ Command: {cmd} Return code: {ret} Standard out: {out} Standard Error: {err} """.format(cmd=self.cmd, ret=ret_code, out=format_out(out), err=format_out(err)) send_mail(self.mail_address, self.mail_header, content)