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 skia | 10 cd skia |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 os.path.join(self._telemetry_binaries_dir, 'record_wpr'), | 226 os.path.join(self._telemetry_binaries_dir, 'record_wpr'), |
227 '--extra-browser-args=--disable-setuid-sandbox', | 227 '--extra-browser-args=--disable-setuid-sandbox', |
228 '--browser=exact', | 228 '--browser=exact', |
229 '--browser-executable=%s' % self._browser_executable, | 229 '--browser-executable=%s' % self._browser_executable, |
230 '%s_page_set' % page_set_basename, | 230 '%s_page_set' % page_set_basename, |
231 '--page-set-base-dir=%s' % page_set_dir | 231 '--page-set-base-dir=%s' % page_set_dir |
232 ) | 232 ) |
233 for _ in range(RETRY_RECORD_WPR_COUNT): | 233 for _ in range(RETRY_RECORD_WPR_COUNT): |
234 try: | 234 try: |
235 shell_utils.run(' '.join(record_wpr_cmd), shell=True) | 235 shell_utils.run(' '.join(record_wpr_cmd), shell=True) |
| 236 |
| 237 # Move over the created archive into the local webpages archive |
| 238 # directory. |
| 239 shutil.move( |
| 240 os.path.join(LOCAL_REPLAY_WEBPAGES_ARCHIVE_DIR, wpr_data_file), |
| 241 self._local_record_webpages_archive_dir) |
| 242 shutil.move( |
| 243 os.path.join(LOCAL_REPLAY_WEBPAGES_ARCHIVE_DIR, |
| 244 page_set_json_name), |
| 245 self._local_record_webpages_archive_dir) |
| 246 |
236 # Break out of the retry loop since there were no errors. | 247 # Break out of the retry loop since there were no errors. |
237 break | 248 break |
238 except Exception: | 249 except Exception: |
239 # There was a failure continue with the loop. | 250 # There was a failure continue with the loop. |
240 traceback.print_exc() | 251 traceback.print_exc() |
241 else: | 252 else: |
242 # If we get here then record_wpr did not succeed and thus did not | 253 # If we get here then record_wpr did not succeed and thus did not |
243 # break out of the loop. | 254 # break out of the loop. |
244 raise Exception('record_wpr failed for page_set: %s' % page_set) | 255 raise Exception('record_wpr failed for page_set: %s' % page_set) |
245 | 256 |
(...skipping 18 matching lines...) Expand all Loading... |
264 | 275 |
265 for _ in range(RETRY_RUN_MEASUREMENT_COUNT): | 276 for _ in range(RETRY_RUN_MEASUREMENT_COUNT): |
266 try: | 277 try: |
267 print '\n\n=======Capturing SKP of %s=======\n\n' % page_set | 278 print '\n\n=======Capturing SKP of %s=======\n\n' % page_set |
268 shell_utils.run(' '.join(run_benchmark_cmd), shell=True) | 279 shell_utils.run(' '.join(run_benchmark_cmd), shell=True) |
269 except shell_utils.CommandFailedException: | 280 except shell_utils.CommandFailedException: |
270 # skpicture_printer sometimes fails with AssertionError but the | 281 # skpicture_printer sometimes fails with AssertionError but the |
271 # captured SKP is still valid. This is a known issue. | 282 # captured SKP is still valid. This is a known issue. |
272 pass | 283 pass |
273 | 284 |
274 if self._record: | |
275 # Move over the created archive into the local webpages archive | |
276 # directory. | |
277 shutil.move( | |
278 os.path.join(LOCAL_REPLAY_WEBPAGES_ARCHIVE_DIR, wpr_data_file), | |
279 self._local_record_webpages_archive_dir) | |
280 shutil.move( | |
281 os.path.join(LOCAL_REPLAY_WEBPAGES_ARCHIVE_DIR, | |
282 page_set_json_name), | |
283 self._local_record_webpages_archive_dir) | |
284 | |
285 # Rename generated SKP files into more descriptive names. | 285 # Rename generated SKP files into more descriptive names. |
286 try: | 286 try: |
287 self._RenameSkpFiles(page_set) | 287 self._RenameSkpFiles(page_set) |
288 # Break out of the retry loop since there were no errors. | 288 # Break out of the retry loop since there were no errors. |
289 break | 289 break |
290 except Exception: | 290 except Exception: |
291 # There was a failure continue with the loop. | 291 # There was a failure continue with the loop. |
292 traceback.print_exc() | 292 traceback.print_exc() |
293 print '\n\n=======Retrying %s=======\n\n' % page_set | 293 print '\n\n=======Retrying %s=======\n\n' % page_set |
294 time.sleep(10) | 294 time.sleep(10) |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 default=None) | 511 default=None) |
512 option_parser.add_option( | 512 option_parser.add_option( |
513 '', '--non-interactive', action='store_true', | 513 '', '--non-interactive', action='store_true', |
514 help='Runs the script without any prompts. If this flag is specified and ' | 514 help='Runs the script without any prompts. If this flag is specified and ' |
515 '--skia_tools is specified then the debugger is not run.', | 515 '--skia_tools is specified then the debugger is not run.', |
516 default=False) | 516 default=False) |
517 options, unused_args = option_parser.parse_args() | 517 options, unused_args = option_parser.parse_args() |
518 | 518 |
519 playback = SkPicturePlayback(options) | 519 playback = SkPicturePlayback(options) |
520 sys.exit(playback.Run()) | 520 sys.exit(playback.Run()) |
OLD | NEW |