def _Email(self, experiment): # Only email by default if a new run was completed. send_mail = False for benchmark_run in experiment.benchmark_runs: if not benchmark_run.cache_hit: send_mail = True break if (not send_mail and not experiment.email_to or config.GetConfig('no_email')): return label_names = [] for label in experiment.labels: label_names.append(label.name) subject = '%s: %s' % (experiment.name, ' vs. '.join(label_names)) text_report = TextResultsReport.FromExperiment(experiment, True).GetReport() text_report += ('\nResults are stored in %s.\n' % experiment.results_directory) text_report = "<pre style='font-size: 13px'>%s</pre>" % text_report html_report = HTMLResultsReport.FromExperiment(experiment).GetReport() attachment = EmailSender.Attachment('report.html', html_report) email_to = experiment.email_to or [] email_to.append(getpass.getuser()) EmailSender().SendEmail(email_to, subject, text_report, attachments=[attachment], msg_type='html')
def _checkReport(self, email): num_success = 2 success_keyvals = {'retval': 0, 'machine': 'some bot', 'a_float': 3.96} experiment = _InjectSuccesses(MakeMockExperiment(), num_success, success_keyvals) text_report = TextResultsReport.FromExperiment(experiment, email=email) \ .GetReport() self.assertIn(str(success_keyvals['a_float']), text_report) self.assertIn(success_keyvals['machine'], text_report) self.assertIn(MockCrosMachine.CPUINFO_STRING, text_report) return text_report
def _StoreResults(self, experiment): if self._terminated: return results_directory = experiment.results_directory FileUtils().RmDir(results_directory) FileUtils().MkDirP(results_directory) self.l.LogOutput('Storing experiment file in %s.' % results_directory) experiment_file_path = os.path.join(results_directory, 'experiment.exp') FileUtils().WriteFile(experiment_file_path, experiment.experiment_file) self.l.LogOutput('Storing results report in %s.' % results_directory) results_table_path = os.path.join(results_directory, 'results.html') report = HTMLResultsReport.FromExperiment(experiment).GetReport() if self.json_report: json_report = JSONResultsReport.FromExperiment( experiment, json_args={'indent': 2}) _WriteJSONReportToFile(experiment, results_directory, json_report) FileUtils().WriteFile(results_table_path, report) self.l.LogOutput('Storing email message body in %s.' % results_directory) msg_file_path = os.path.join(results_directory, 'msg_body.html') text_report = TextResultsReport.FromExperiment(experiment, True).GetReport() text_report += ('\nResults are stored in %s.\n' % experiment.results_directory) msg_body = "<pre style='font-size: 13px'>%s</pre>" % text_report FileUtils().WriteFile(msg_file_path, msg_body) self.l.LogOutput('Storing results of each benchmark run.') for benchmark_run in experiment.benchmark_runs: if benchmark_run.result: benchmark_run_name = filter(str.isalnum, benchmark_run.name) benchmark_run_path = os.path.join(results_directory, benchmark_run_name) benchmark_run.result.CopyResultsTo(benchmark_run_path) benchmark_run.result.CleanUp( benchmark_run.benchmark.rm_chroot_tmp)
def _PrintTable(self, experiment): self.l.LogOutput( TextResultsReport.FromExperiment(experiment).GetReport())