OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Archives or replays webpages and creates SKPs in a Google Storage location. | 6 """Archives or replays webpages and creates SKPs in a Google Storage location. |
7 | 7 |
8 To archive webpages and store SKP files (archives should be rarely updated): | 8 To archive webpages and store SKP files (archives should be rarely updated): |
9 | 9 |
10 cd ../buildbot/slave/skia_slave_scripts | 10 cd ../buildbot/slave/skia_slave_scripts |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 os.path.abspath(os.path.dirname(__file__)), 'page_sets', 'data') | 73 os.path.abspath(os.path.dirname(__file__)), 'page_sets', 'data') |
74 TMP_SKP_DIR = tempfile.mkdtemp() | 74 TMP_SKP_DIR = tempfile.mkdtemp() |
75 | 75 |
76 # Location of the credentials.json file and the string that represents missing | 76 # Location of the credentials.json file and the string that represents missing |
77 # passwords. | 77 # passwords. |
78 CREDENTIALS_FILE_PATH = os.path.join( | 78 CREDENTIALS_FILE_PATH = os.path.join( |
79 os.path.abspath(os.path.dirname(__file__)), 'page_sets', 'data', | 79 os.path.abspath(os.path.dirname(__file__)), 'page_sets', 'data', |
80 'credentials.json' | 80 'credentials.json' |
81 ) | 81 ) |
82 | 82 |
83 # Stdout that signifies that a recording has failed. | |
84 RECORD_FAILURE_MSG = 'The recording has not been updated for these pages.' | |
85 | |
86 # Name of the SKP benchmark | 83 # Name of the SKP benchmark |
87 SKP_BENCHMARK = 'skpicture_printer' | 84 SKP_BENCHMARK = 'skpicture_printer' |
88 | 85 |
89 # The max base name length of Skp files. | 86 # The max base name length of Skp files. |
90 MAX_SKP_BASE_NAME_LEN = 31 | 87 MAX_SKP_BASE_NAME_LEN = 31 |
91 | 88 |
92 # Dictionary of device to platform prefixes for SKP files. | 89 # Dictionary of device to platform prefixes for SKP files. |
93 DEVICE_TO_PLATFORM_PREFIX = { | 90 DEVICE_TO_PLATFORM_PREFIX = { |
94 'desktop': 'desk', | 91 'desktop': 'desk', |
95 'galaxynexus': 'mobi', | 92 'galaxynexus': 'mobi', |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 'PYTHONPATH=%s:$PYTHONPATH' % page_set_dir, | 211 'PYTHONPATH=%s:$PYTHONPATH' % page_set_dir, |
215 'DISPLAY=%s' % X11_DISPLAY, | 212 'DISPLAY=%s' % X11_DISPLAY, |
216 os.path.join(self._telemetry_binaries_dir, 'record_wpr'), | 213 os.path.join(self._telemetry_binaries_dir, 'record_wpr'), |
217 '--extra-browser-args=--disable-setuid-sandbox', | 214 '--extra-browser-args=--disable-setuid-sandbox', |
218 '--browser=exact', | 215 '--browser=exact', |
219 '--browser-executable=%s' % self._browser_executable, | 216 '--browser-executable=%s' % self._browser_executable, |
220 '%s_page_set' % page_set_basename, | 217 '%s_page_set' % page_set_basename, |
221 '--page-set-base-dir=%s' % page_set_dir | 218 '--page-set-base-dir=%s' % page_set_dir |
222 ) | 219 ) |
223 for _ in range(RETRY_RECORD_WPR_COUNT): | 220 for _ in range(RETRY_RECORD_WPR_COUNT): |
224 output = shell_utils.run(' '.join(record_wpr_cmd), shell=True) | 221 try: |
225 if RECORD_FAILURE_MSG in output: | 222 shell_utils.run(' '.join(record_wpr_cmd), shell=True) |
226 print output | |
227 else: | |
228 # Break out of the retry loop since there were no errors. | 223 # Break out of the retry loop since there were no errors. |
229 break | 224 break |
| 225 except Exception: |
| 226 # There was a failure continue with the loop. |
| 227 traceback.print_exc() |
230 else: | 228 else: |
231 # If we get here then record_wpr did not succeed and thus did not | 229 # If we get here then record_wpr did not succeed and thus did not |
232 # break out of the loop. | 230 # break out of the loop. |
233 raise Exception('record_wpr failed for page_set: %s' % page_set) | 231 raise Exception('record_wpr failed for page_set: %s' % page_set) |
234 | 232 |
235 else: | 233 else: |
236 if not self._skip_all_gs_access: | 234 if not self._skip_all_gs_access: |
237 # Get the webpages archive so that it can be replayed. | 235 # Get the webpages archive so that it can be replayed. |
238 self._DownloadWebpagesArchive(wpr_data_file, page_set_json_name) | 236 self._DownloadWebpagesArchive(wpr_data_file, page_set_json_name) |
239 | 237 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 '-r', self._local_skp_dir | 294 '-r', self._local_skp_dir |
297 ] | 295 ] |
298 render_pdfs_cmd = [ | 296 render_pdfs_cmd = [ |
299 os.path.join(self._skia_tools, 'render_pdfs'), | 297 os.path.join(self._skia_tools, 'render_pdfs'), |
300 self._local_skp_dir | 298 self._local_skp_dir |
301 ] | 299 ] |
302 | 300 |
303 for tools_cmd in (render_pictures_cmd, render_pdfs_cmd): | 301 for tools_cmd in (render_pictures_cmd, render_pdfs_cmd): |
304 print '\n\n=======Running %s=======' % ' '.join(tools_cmd) | 302 print '\n\n=======Running %s=======' % ' '.join(tools_cmd) |
305 proc = subprocess.Popen(tools_cmd) | 303 proc = subprocess.Popen(tools_cmd) |
306 (code, output) = shell_utils.log_process_after_completion(proc, | 304 (code, _) = shell_utils.log_process_after_completion(proc, echo=False) |
307 echo=False) | |
308 if code != 0: | 305 if code != 0: |
309 raise Exception('%s failed!' % ' '.join(tools_cmd)) | 306 raise Exception('%s failed!' % ' '.join(tools_cmd)) |
310 | 307 |
311 if not self._non_interactive: | 308 if not self._non_interactive: |
312 print '\n\n=======Running debugger=======' | 309 print '\n\n=======Running debugger=======' |
313 os.system('%s %s' % (os.path.join(self._skia_tools, 'debugger'), | 310 os.system('%s %s' % (os.path.join(self._skia_tools, 'debugger'), |
314 os.path.join(self._local_skp_dir, '*'))) | 311 os.path.join(self._local_skp_dir, '*'))) |
315 | 312 |
316 print '\n\n' | 313 print '\n\n' |
317 | 314 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 default=None) | 449 default=None) |
453 option_parser.add_option( | 450 option_parser.add_option( |
454 '', '--non-interactive', action='store_true', | 451 '', '--non-interactive', action='store_true', |
455 help='Runs the script without any prompts. If this flag is specified and ' | 452 help='Runs the script without any prompts. If this flag is specified and ' |
456 '--skia_tools is specified then the debugger is not run.', | 453 '--skia_tools is specified then the debugger is not run.', |
457 default=False) | 454 default=False) |
458 options, unused_args = option_parser.parse_args() | 455 options, unused_args = option_parser.parse_args() |
459 | 456 |
460 playback = SkPicturePlayback(options) | 457 playback = SkPicturePlayback(options) |
461 sys.exit(playback.Run()) | 458 sys.exit(playback.Run()) |
OLD | NEW |