| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import datetime | 5 import datetime |
| 6 import json | 6 import json |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 | 9 |
| 10 from catapult_base import cloud_storage | 10 from catapult_base import cloud_storage |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 vulcanizer = project.CreateVulcanizer() | 38 vulcanizer = project.CreateVulcanizer() |
| 39 modules = ['tracing.results2_template'] | 39 modules = ['tracing.results2_template'] |
| 40 load_sequence = vulcanizer.CalcLoadSequenceForModuleNames(modules) | 40 load_sequence = vulcanizer.CalcLoadSequenceForModuleNames(modules) |
| 41 return generate.GenerateStandaloneHTMLAsString(load_sequence) | 41 return generate.GenerateStandaloneHTMLAsString(load_sequence) |
| 42 | 42 |
| 43 def Format(self, page_test_results): | 43 def Format(self, page_test_results): |
| 44 with file(self._output_filename, 'a') as f: | 44 with file(self._output_filename, 'a') as f: |
| 45 f.write('\n'.join([ | 45 f.write('\n'.join([ |
| 46 '', | 46 '', |
| 47 '<script>', | 47 '<script>', |
| 48 'values.addValueDicts(%s);' % json.dumps(page_test_results.value_set), | 48 'values.addValuesFromDicts(%s);' % json.dumps( |
| 49 page_test_results.value_set), |
| 49 '</script>', | 50 '</script>', |
| 50 ''])) | 51 ''])) |
| 51 | 52 |
| 52 if self._upload_results: | 53 if self._upload_results: |
| 53 file_path = os.path.abspath(self._output_stream.name) | 54 file_path = os.path.abspath(self._output_stream.name) |
| 54 file_name = 'html-results/results-%s' % datetime.datetime.now().strftime( | 55 file_name = 'html-results/results-%s' % datetime.datetime.now().strftime( |
| 55 '%Y-%m-%d_%H-%M-%S') | 56 '%Y-%m-%d_%H-%M-%S') |
| 56 try: | 57 try: |
| 57 cloud_storage.Insert(cloud_storage.PUBLIC_BUCKET, file_name, file_path) | 58 cloud_storage.Insert(cloud_storage.PUBLIC_BUCKET, file_name, file_path) |
| 58 print | 59 print |
| 59 print ('View online at ' | 60 print ('View online at ' |
| 60 'http://storage.googleapis.com/chromium-telemetry/%s' | 61 'http://storage.googleapis.com/chromium-telemetry/%s' |
| 61 % file_name) | 62 % file_name) |
| 62 except cloud_storage.PermissionError as e: | 63 except cloud_storage.PermissionError as e: |
| 63 logging.error('Cannot upload profiling files to cloud storage due to ' | 64 logging.error('Cannot upload profiling files to cloud storage due to ' |
| 64 ' permission error: %s' % e.message) | 65 ' permission error: %s' % e.message) |
| 65 print | 66 print |
| 66 print 'View result at file://%s' % os.path.abspath( | 67 print 'View result at file://%s' % os.path.abspath( |
| 67 self._output_stream.name) | 68 self._output_stream.name) |
| OLD | NEW |