Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: tools/skp/webpages_playback.py

Issue 1053253003: Delete no longer needed pagesets, add new pagesets and make names more readable (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Fix copyright year Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 # skia_yahooanswers_desktop -> skia, yahooanswers, desktop 379 # skia_yahooanswers_desktop -> skia, yahooanswers, desktop
380 _, page_name, device = ps_basename.split('_') 380 _, page_name, device = ps_basename.split('_')
381 basename = '%s_%s' % (DEVICE_TO_PLATFORM_PREFIX[device], page_name) 381 basename = '%s_%s' % (DEVICE_TO_PLATFORM_PREFIX[device], page_name)
382 return basename[:MAX_SKP_BASE_NAME_LEN] + '.skp' 382 return basename[:MAX_SKP_BASE_NAME_LEN] + '.skp'
383 383
384 def _GetChromiumSkpFileName(self, page_set, site): 384 def _GetChromiumSkpFileName(self, page_set, site):
385 """Returns the SKP file name for Chromium page sets.""" 385 """Returns the SKP file name for Chromium page sets."""
386 # /path/to/http___mobile_news_sandbox_pt0 -> http___mobile_news_sandbox_pt0 386 # /path/to/http___mobile_news_sandbox_pt0 -> http___mobile_news_sandbox_pt0
387 _, webpage = os.path.split(site) 387 _, webpage = os.path.split(site)
388 # http___mobile_news_sandbox_pt0 -> mobile_news_sandbox_pt0 388 # http___mobile_news_sandbox_pt0 -> mobile_news_sandbox_pt0
389 for prefix in ('http___', 'https___'): 389 for prefix in ('http___', 'https___', 'www_'):
390 if webpage.startswith(prefix): 390 if webpage.startswith(prefix):
391 webpage = webpage[len(prefix):] 391 webpage = webpage[len(prefix):]
392 # /path/to/skia_yahooanswers_desktop.py -> skia_yahooanswers_desktop.py 392 # /path/to/skia_yahooanswers_desktop.py -> skia_yahooanswers_desktop.py
393 ps_filename = os.path.basename(page_set) 393 ps_filename = os.path.basename(page_set)
394 # http___mobile_news_sandbox -> pagesetprefix_http___mobile_news_sandbox 394 # http___mobile_news_sandbox -> pagesetprefix_http___mobile_news_sandbox
395 basename = '%s_%s' % (CHROMIUM_PAGE_SETS_TO_PREFIX[ps_filename], webpage) 395 basename = '%s_%s' % (CHROMIUM_PAGE_SETS_TO_PREFIX[ps_filename], webpage)
396 return basename[:MAX_SKP_BASE_NAME_LEN] + '.skp' 396 return basename[:MAX_SKP_BASE_NAME_LEN] + '.skp'
397 397
398 def _RenameSkpFiles(self, page_set): 398 def _RenameSkpFiles(self, page_set):
399 """Rename generated SKP files into more descriptive names. 399 """Rename generated SKP files into more descriptive names.
400 400
401 Look into the subdirectory of TMP_SKP_DIR and find the most interesting 401 Look into the subdirectory of TMP_SKP_DIR and find the most interesting
402 .skp in there to be this page_set's representative .skp. 402 .skp in there to be this page_set's representative .skp.
403 """ 403 """
404 subdirs = glob.glob(os.path.join(TMP_SKP_DIR, '*')) 404 subdirs = glob.glob(os.path.join(TMP_SKP_DIR, '*'))
405 for site in subdirs: 405 for site in subdirs:
406 if self._IsChromiumPageSet(page_set): 406 if self._IsChromiumPageSet(page_set):
407 filename = self._GetChromiumSkpFileName(page_set, site) 407 filename = self._GetChromiumSkpFileName(page_set, site)
408 else: 408 else:
409 filename = self._GetSkiaSkpFileName(page_set) 409 filename = self._GetSkiaSkpFileName(page_set)
410 filename = filename.lower()
410 411
411 # We choose the largest .skp as the most likely to be interesting. 412 # We choose the largest .skp as the most likely to be interesting.
412 largest_skp = max(glob.glob(os.path.join(site, '*.skp')), 413 largest_skp = max(glob.glob(os.path.join(site, '*.skp')),
413 key=lambda path: os.stat(path).st_size) 414 key=lambda path: os.stat(path).st_size)
414 dest = os.path.join(self._local_skp_dir, filename) 415 dest = os.path.join(self._local_skp_dir, filename)
415 print 'Moving', largest_skp, 'to', dest 416 print 'Moving', largest_skp, 'to', dest
416 shutil.move(largest_skp, dest) 417 shutil.move(largest_skp, dest)
417 self._skp_files.append(filename) 418 self._skp_files.append(filename)
418 shutil.rmtree(site) 419 shutil.rmtree(site)
419 420
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 default=None) 551 default=None)
551 option_parser.add_option( 552 option_parser.add_option(
552 '', '--non-interactive', action='store_true', 553 '', '--non-interactive', action='store_true',
553 help='Runs the script without any prompts. If this flag is specified and ' 554 help='Runs the script without any prompts. If this flag is specified and '
554 '--skia_tools is specified then the debugger is not run.', 555 '--skia_tools is specified then the debugger is not run.',
555 default=False) 556 default=False)
556 options, unused_args = option_parser.parse_args() 557 options, unused_args = option_parser.parse_args()
557 558
558 playback = SkPicturePlayback(options) 559 playback = SkPicturePlayback(options)
559 sys.exit(playback.Run()) 560 sys.exit(playback.Run())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698