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

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

Issue 780493002: Remove Google Storage scheme prefix correctly from gs base name in webpages_playback (Closed) Base URL: https://skia.googlesource.com/skia.git@webpages-replay-run-render-pdf
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ../buildbot/slave/skia_slave_scripts 10 cd ../buildbot/slave/skia_slave_scripts
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 CREDENTIALS_GS_PATH = '/playback/credentials/credentials.json' 102 CREDENTIALS_GS_PATH = '/playback/credentials/credentials.json'
103 103
104 X11_DISPLAY = os.getenv('DISPLAY', ':0') 104 X11_DISPLAY = os.getenv('DISPLAY', ':0')
105 105
106 GS_PREDEFINED_ACL = gs_utils.GSUtils.PredefinedACL.PRIVATE 106 GS_PREDEFINED_ACL = gs_utils.GSUtils.PredefinedACL.PRIVATE
107 GS_FINE_GRAINED_ACL_LIST = [ 107 GS_FINE_GRAINED_ACL_LIST = [
108 (gs_utils.GSUtils.IdType.GROUP_BY_DOMAIN, 'google.com', 108 (gs_utils.GSUtils.IdType.GROUP_BY_DOMAIN, 'google.com',
109 gs_utils.GSUtils.Permission.READ), 109 gs_utils.GSUtils.Permission.READ),
110 ] 110 ]
111 111
112 def remove_prefix(s, prefix):
113 if s.startswith(prefix):
114 return s[len(prefix):]
115 return s
112 116
113 class SkPicturePlayback(object): 117 class SkPicturePlayback(object):
114 """Class that archives or replays webpages and creates SKPs.""" 118 """Class that archives or replays webpages and creates SKPs."""
115 119
116 def __init__(self, parse_options): 120 def __init__(self, parse_options):
117 """Constructs a SkPicturePlayback BuildStep instance.""" 121 """Constructs a SkPicturePlayback BuildStep instance."""
118 assert parse_options.browser_executable, 'Must specify --browser_executable' 122 assert parse_options.browser_executable, 'Must specify --browser_executable'
119 self._browser_executable = parse_options.browser_executable 123 self._browser_executable = parse_options.browser_executable
120 124
121 self._all_page_sets_specified = parse_options.page_sets == 'all' 125 self._all_page_sets_specified = parse_options.page_sets == 'all'
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 "password": "google_testing_account_password" 174 "password": "google_testing_account_password"
171 }, 175 },
172 "facebook": { 176 "facebook": {
173 "username": "facebook_testing_account_username", 177 "username": "facebook_testing_account_username",
174 "password": "facebook_testing_account_password" 178 "password": "facebook_testing_account_password"
175 } 179 }
176 }\n\n""" % CREDENTIALS_FILE_PATH 180 }\n\n""" % CREDENTIALS_FILE_PATH
177 raw_input("Please press a key when you are ready to proceed...") 181 raw_input("Please press a key when you are ready to proceed...")
178 elif not os.path.isfile(CREDENTIALS_FILE_PATH): 182 elif not os.path.isfile(CREDENTIALS_FILE_PATH):
179 # Download the credentials.json file from Google Storage. 183 # Download the credentials.json file from Google Storage.
180 gs_bucket = self._dest_gsbase.lstrip(gs_utils.GS_PREFIX) 184 gs_bucket = remove_prefix(self._dest_gsbase.lstrip(), gs_utils.GS_PREFIX)
181 gs_utils.GSUtils().download_file(gs_bucket, CREDENTIALS_GS_PATH, 185 gs_utils.GSUtils().download_file(gs_bucket, CREDENTIALS_GS_PATH,
182 CREDENTIALS_FILE_PATH) 186 CREDENTIALS_FILE_PATH)
183 187
184 # Delete any left over data files in the data directory. 188 # Delete any left over data files in the data directory.
185 for archive_file in glob.glob( 189 for archive_file in glob.glob(
186 os.path.join(LOCAL_REPLAY_WEBPAGES_ARCHIVE_DIR, 'skia_*')): 190 os.path.join(LOCAL_REPLAY_WEBPAGES_ARCHIVE_DIR, 'skia_*')):
187 os.remove(archive_file) 191 os.remove(archive_file)
188 192
189 # Delete the local root directory if it already exists. 193 # Delete the local root directory if it already exists.
190 if os.path.exists(LOCAL_PLAYBACK_ROOT_DIR): 194 if os.path.exists(LOCAL_PLAYBACK_ROOT_DIR):
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 316
313 print '\n\n' 317 print '\n\n'
314 318
315 if not self._skip_all_gs_access and self._upload_to_gs: 319 if not self._skip_all_gs_access and self._upload_to_gs:
316 print '\n\n=======Uploading to Google Storage=======\n\n' 320 print '\n\n=======Uploading to Google Storage=======\n\n'
317 # Copy the directory structure in the root directory into Google Storage. 321 # Copy the directory structure in the root directory into Google Storage.
318 dest_dir_name = ROOT_PLAYBACK_DIR_NAME 322 dest_dir_name = ROOT_PLAYBACK_DIR_NAME
319 if self._alternate_upload_dir: 323 if self._alternate_upload_dir:
320 dest_dir_name = self._alternate_upload_dir 324 dest_dir_name = self._alternate_upload_dir
321 325
322 gs_bucket = self._dest_gsbase.lstrip(gs_utils.GS_PREFIX) 326 gs_bucket = remove_prefix(self._dest_gsbase.lstrip(), gs_utils.GS_PREFIX)
323 gs_utils.GSUtils().upload_dir_contents( 327 gs_utils.GSUtils().upload_dir_contents(
324 LOCAL_PLAYBACK_ROOT_DIR, gs_bucket, dest_dir_name, 328 LOCAL_PLAYBACK_ROOT_DIR, gs_bucket, dest_dir_name,
325 upload_if=gs_utils.GSUtils.UploadIf.IF_MODIFIED, 329 upload_if=gs_utils.GSUtils.UploadIf.IF_MODIFIED,
326 predefined_acl=GS_PREDEFINED_ACL, 330 predefined_acl=GS_PREDEFINED_ACL,
327 fine_grained_acl_list=GS_FINE_GRAINED_ACL_LIST) 331 fine_grained_acl_list=GS_FINE_GRAINED_ACL_LIST)
328 332
329 print '\n\n=======New SKPs have been uploaded to %s =======\n\n' % ( 333 print '\n\n=======New SKPs have been uploaded to %s =======\n\n' % (
330 posixpath.join(self._dest_gsbase, dest_dir_name, SKPICTURES_DIR_NAME)) 334 posixpath.join(self._dest_gsbase, dest_dir_name, SKPICTURES_DIR_NAME))
331 else: 335 else:
332 print '\n\n=======Not Uploading to Google Storage=======\n\n' 336 print '\n\n=======Not Uploading to Google Storage=======\n\n'
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 os.makedirs(d) 379 os.makedirs(d)
376 380
377 def _DownloadWebpagesArchive(self, wpr_data_file, page_set_json_name): 381 def _DownloadWebpagesArchive(self, wpr_data_file, page_set_json_name):
378 """Downloads the webpages archive and its required page set from GS.""" 382 """Downloads the webpages archive and its required page set from GS."""
379 wpr_source = posixpath.join(ROOT_PLAYBACK_DIR_NAME, 'webpages_archive', 383 wpr_source = posixpath.join(ROOT_PLAYBACK_DIR_NAME, 'webpages_archive',
380 wpr_data_file) 384 wpr_data_file)
381 page_set_source = posixpath.join(ROOT_PLAYBACK_DIR_NAME, 385 page_set_source = posixpath.join(ROOT_PLAYBACK_DIR_NAME,
382 'webpages_archive', 386 'webpages_archive',
383 page_set_json_name) 387 page_set_json_name)
384 gs = gs_utils.GSUtils() 388 gs = gs_utils.GSUtils()
385 gs_bucket = self._dest_gsbase.lstrip(gs_utils.GS_PREFIX) 389 gs_bucket = remove_prefix(self._dest_gsbase.lstrip(), gs_utils.GS_PREFIX)
386 if (gs.does_storage_object_exist(gs_bucket, wpr_source) and 390 if (gs.does_storage_object_exist(gs_bucket, wpr_source) and
387 gs.does_storage_object_exist(gs_bucket, page_set_source)): 391 gs.does_storage_object_exist(gs_bucket, page_set_source)):
388 gs.download_file(gs_bucket, wpr_source, 392 gs.download_file(gs_bucket, wpr_source,
389 os.path.join(LOCAL_REPLAY_WEBPAGES_ARCHIVE_DIR, 393 os.path.join(LOCAL_REPLAY_WEBPAGES_ARCHIVE_DIR,
390 wpr_data_file)) 394 wpr_data_file))
391 gs.download_file(gs_bucket, page_set_source, 395 gs.download_file(gs_bucket, page_set_source,
392 os.path.join(LOCAL_REPLAY_WEBPAGES_ARCHIVE_DIR, 396 os.path.join(LOCAL_REPLAY_WEBPAGES_ARCHIVE_DIR,
393 page_set_json_name)) 397 page_set_json_name))
394 else: 398 else:
395 raise Exception('%s and %s do not exist in Google Storage!' % ( 399 raise Exception('%s and %s do not exist in Google Storage!' % (
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 default=None) 453 default=None)
450 option_parser.add_option( 454 option_parser.add_option(
451 '', '--non-interactive', action='store_true', 455 '', '--non-interactive', action='store_true',
452 help='Runs the script without any prompts. If this flag is specified and ' 456 help='Runs the script without any prompts. If this flag is specified and '
453 '--skia_tools is specified then the debugger is not run.', 457 '--skia_tools is specified then the debugger is not run.',
454 default=False) 458 default=False)
455 options, unused_args = option_parser.parse_args() 459 options, unused_args = option_parser.parse_args()
456 460
457 playback = SkPicturePlayback(options) 461 playback = SkPicturePlayback(options)
458 sys.exit(playback.Run()) 462 sys.exit(playback.Run())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698