OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import random | 9 import random |
10 import shutil | 10 import shutil |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 trace_files.append(file_path) | 66 trace_files.append(file_path) |
67 counter += 1 | 67 counter += 1 |
68 tf = tempfile.NamedTemporaryFile(delete=False, suffix='.html') | 68 tf = tempfile.NamedTemporaryFile(delete=False, suffix='.html') |
69 tf.close() | 69 tf.close() |
70 if trace_files: | 70 if trace_files: |
71 title = '' | 71 title = '' |
72 if self.page: | 72 if self.page: |
73 title = self.page.display_name | 73 title = self.page.display_name |
74 cmd = (['python', _TRACE2HTML_PATH] + trace_files + | 74 cmd = (['python', _TRACE2HTML_PATH] + trace_files + |
75 ['--output', tf.name] + ['--title', title]) | 75 ['--output', tf.name] + ['--title', title]) |
76 subprocess.check_call(cmd) | 76 subprocess.check_output(cmd) |
77 else: | 77 else: |
78 logging.warning('No traces to convert to html.') | 78 logging.warning('No traces to convert to html.') |
79 return file_handle.FromTempFile(tf) | 79 return file_handle.FromTempFile(tf) |
80 finally: | 80 finally: |
81 shutil.rmtree(temp_dir) | 81 shutil.rmtree(temp_dir) |
82 | 82 |
83 def __repr__(self): | 83 def __repr__(self): |
84 if self.page: | 84 if self.page: |
85 page_name = self.page.display_name | 85 page_name = self.page.display_name |
86 else: | 86 else: |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 fh.extension)) | 175 fh.extension)) |
176 self._cloud_url = cloud_storage.Insert( | 176 self._cloud_url = cloud_storage.Insert( |
177 bucket, remote_path, fh.GetAbsPath()) | 177 bucket, remote_path, fh.GetAbsPath()) |
178 sys.stderr.write( | 178 sys.stderr.write( |
179 'View generated trace files online at %s for page %s\n' % | 179 'View generated trace files online at %s for page %s\n' % |
180 (self._cloud_url, self.page.url if self.page else 'unknown')) | 180 (self._cloud_url, self.page.url if self.page else 'unknown')) |
181 return self._cloud_url | 181 return self._cloud_url |
182 except cloud_storage.PermissionError as e: | 182 except cloud_storage.PermissionError as e: |
183 logging.error('Cannot upload trace files to cloud storage due to ' | 183 logging.error('Cannot upload trace files to cloud storage due to ' |
184 ' permission error: %s' % e.message) | 184 ' permission error: %s' % e.message) |
OLD | NEW |