Beispiel #1
0
    def testBasic(self):
        value0 = {'foo': 0}
        value0_json = json.dumps(value0, separators=(',', ':'))

        results_renderer.RenderHTMLView([], self.output_stream, False)
        self.output_stream.seek(0)
        self.assertEquals([],
                          results_renderer.ReadExistingResults(
                              self.output_stream.read()))
        results_renderer.RenderHTMLView([value0], self.output_stream, False)
        self.output_stream.seek(0)
        self.assertEquals(
            sorted([value0]),
            sorted(
                results_renderer.ReadExistingResults(
                    self.output_stream.read())))
        self.assertIn(value0_json, self.GetOutputFileContent())
Beispiel #2
0
 def Format(self, page_test_results):
   results_renderer.RenderHTMLView(page_test_results.value_set,
                                   self._output_stream, self._reset_results)
   file_path = os.path.abspath(self._output_stream.name)
   if self._upload_results:
     remote_path = ('html-results/results-%s' %
                    datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S'))
     try:
       cloud_storage.Insert(
           cloud_storage.PUBLIC_BUCKET, remote_path, file_path)
       print 'View online at',
       print 'http://storage.googleapis.com/chromium-telemetry/' + remote_path
     except cloud_storage.PermissionError as e:
       logging.error('Cannot upload profiling files to cloud storage due ' +
                     'to permission error: ' + e.message)
   print 'View result at file://' + file_path
  def Format(self, page_test_results):
    histograms = page_test_results.histograms
    if not histograms:
      histograms = self._ConvertChartJson(page_test_results)
    if isinstance(histograms, histogram_set.HistogramSet):
      histograms = histograms.AsDicts()

    results_renderer.RenderHTMLView(
        histograms,
        self._output_stream, self._reset_results)
    file_path = os.path.abspath(self._output_stream.name)
    if self._upload_bucket:
      remote_path = ('html-results/results-%s' %
                     datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S'))
      try:
        url = cloud_storage.Insert(self._upload_bucket, remote_path, file_path)
        print 'View HTML results online at %s' % url
      except cloud_storage.PermissionError as e:
        logging.error('Cannot upload profiling files to cloud storage due to '
                      ' permission error: %s' % e.message)
Beispiel #4
0
    def Format(self, page_test_results):
        histograms = page_test_results.value_set
        if not histograms:
            histograms = self.ConvertChartJson_(page_test_results)

        results_renderer.RenderHTMLView(histograms, self._output_stream,
                                        self._reset_results)
        file_path = os.path.abspath(self._output_stream.name)
        if self._upload_results and self._upload_bucket:
            remote_path = (
                'html-results/results-%s' %
                datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S'))
            try:
                cloud_storage.Insert(self._upload_bucket, remote_path,
                                     file_path)
                print 'View online at',
                print 'http://storage.googleapis.com/{bucket}/{path}'.format(
                    bucket=self._upload_bucket, path=remote_path)
            except cloud_storage.PermissionError as e:
                logging.error(
                    'Cannot upload profiling files to cloud storage due ' +
                    'to permission error: ' + e.message)
        print 'View result at file://' + file_path