def RunBenchmark(self): """Run the benchmark.""" results = self.bmark.Run(self.test_records) index = [] if self.options.upload_results in (1, True): connector = site_connector.SiteConnector(self.options, status_callback=self.UpdateStatus) index_hosts = connector.GetIndexHosts() if index_hosts: index = self.bmark.RunIndex(index_hosts) else: index = [] self.DiscoverLocation() if len(self.nameservers) > 1: self.nameservers.RunPortBehaviorThreads() self.reporter = reporter.ReportGenerator(self.options, self.nameservers, results, index=index, geodata=self.geodata)
def CreateReports(self): """Create CSV & HTML reports for the latest run.""" if self.options.output_file: self.report_path = self.options.output_file else: self.report_path = util.GenerateOutputFilename( self.options.template) if self.options.csv_file: self.csv_path = self.options_csv_file else: self.csv_path = util.GenerateOutputFilename('csv') if self.options.upload_results in (1, True): # This is for debugging and transparency only. self.json_path = util.GenerateOutputFilename('js') self.UpdateStatus('Saving anonymized JSON to %s' % self.json_path) json_data = self.reporter.CreateJsonData() f = open(self.json_path, 'w') f.write(json_data) f.close() self.UpdateStatus('Uploading results to %s' % self.options.site_url) connector = site_connector.SiteConnector( self.options, status_callback=self.UpdateStatus) self.url, self.share_state = connector.UploadJsonResults( json_data, hide_results=self.options.hide_results) if self.url: self.UpdateStatus('Your sharing URL: %s (%s)' % (self.url, self.share_state)) self.UpdateStatus('Saving report to %s' % self.report_path) f = open(self.report_path, 'w') self.reporter.CreateReport(format=self.options.template, output_fp=f, csv_path=self.csv_path, sharing_url=self.url, sharing_state=self.share_state) f.close() self.UpdateStatus('Saving detailed results to %s' % self.csv_path) self.reporter.SaveResultsToCsv(self.csv_path)