| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 from common.py.utils import gs_utils | 71 from common.py.utils import gs_utils |
| 72 from common.py.utils import shell_utils | 72 from common.py.utils import shell_utils |
| 73 | 73 |
| 74 ROOT_PLAYBACK_DIR_NAME = 'playback' | 74 ROOT_PLAYBACK_DIR_NAME = 'playback' |
| 75 SKPICTURES_DIR_NAME = 'skps' | 75 SKPICTURES_DIR_NAME = 'skps' |
| 76 | 76 |
| 77 PARTNERS_GS_BUCKET = 'gs://chrome-partner-telemetry' | 77 PARTNERS_GS_BUCKET = 'gs://chrome-partner-telemetry' |
| 78 | 78 |
| 79 # Local archive and SKP directories. | 79 # Local archive and SKP directories. |
| 80 LOCAL_PLAYBACK_ROOT_DIR = os.path.join( | |
| 81 tempfile.gettempdir(), ROOT_PLAYBACK_DIR_NAME) | |
| 82 LOCAL_REPLAY_WEBPAGES_ARCHIVE_DIR = os.path.join( | 80 LOCAL_REPLAY_WEBPAGES_ARCHIVE_DIR = os.path.join( |
| 83 os.path.abspath(os.path.dirname(__file__)), 'page_sets', 'data') | 81 os.path.abspath(os.path.dirname(__file__)), 'page_sets', 'data') |
| 84 TMP_SKP_DIR = tempfile.mkdtemp() | 82 TMP_SKP_DIR = tempfile.mkdtemp() |
| 85 | 83 |
| 86 # Location of the credentials.json file and the string that represents missing | 84 # Location of the credentials.json file and the string that represents missing |
| 87 # passwords. | 85 # passwords. |
| 88 CREDENTIALS_FILE_PATH = os.path.join( | 86 CREDENTIALS_FILE_PATH = os.path.join( |
| 89 os.path.abspath(os.path.dirname(__file__)), 'page_sets', 'data', | 87 os.path.abspath(os.path.dirname(__file__)), 'page_sets', 'data', |
| 90 'credentials.json' | 88 'credentials.json' |
| 91 ) | 89 ) |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 "password": "facebook_testing_account_password" | 223 "password": "facebook_testing_account_password" |
| 226 } | 224 } |
| 227 }\n\n""" % CREDENTIALS_FILE_PATH | 225 }\n\n""" % CREDENTIALS_FILE_PATH |
| 228 raw_input("Please press a key when you are ready to proceed...") | 226 raw_input("Please press a key when you are ready to proceed...") |
| 229 | 227 |
| 230 # Delete any left over data files in the data directory. | 228 # Delete any left over data files in the data directory. |
| 231 for archive_file in glob.glob( | 229 for archive_file in glob.glob( |
| 232 os.path.join(LOCAL_REPLAY_WEBPAGES_ARCHIVE_DIR, 'skia_*')): | 230 os.path.join(LOCAL_REPLAY_WEBPAGES_ARCHIVE_DIR, 'skia_*')): |
| 233 os.remove(archive_file) | 231 os.remove(archive_file) |
| 234 | 232 |
| 235 # Delete the local root directory if it already exists. | |
| 236 if os.path.exists(LOCAL_PLAYBACK_ROOT_DIR): | |
| 237 shutil.rmtree(LOCAL_PLAYBACK_ROOT_DIR) | |
| 238 | |
| 239 # Create the required local storage directories. | 233 # Create the required local storage directories. |
| 240 self._CreateLocalStorageDirs() | 234 self._CreateLocalStorageDirs() |
| 241 | 235 |
| 242 # Start the timer. | 236 # Start the timer. |
| 243 start_time = time.time() | 237 start_time = time.time() |
| 244 | 238 |
| 245 # Loop through all page_sets. | 239 # Loop through all page_sets. |
| 246 for page_set in self._page_sets: | 240 for page_set in self._page_sets: |
| 247 | 241 |
| 248 page_set_basename = os.path.basename(page_set).split('.')[0] | 242 page_set_basename = os.path.basename(page_set).split('.')[0] |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 print '\n\n' | 354 print '\n\n' |
| 361 | 355 |
| 362 if self._upload: | 356 if self._upload: |
| 363 print '\n\n=======Uploading to %s=======\n\n' % self.gs.target_type() | 357 print '\n\n=======Uploading to %s=======\n\n' % self.gs.target_type() |
| 364 # Copy the directory structure in the root directory into Google Storage. | 358 # Copy the directory structure in the root directory into Google Storage. |
| 365 dest_dir_name = ROOT_PLAYBACK_DIR_NAME | 359 dest_dir_name = ROOT_PLAYBACK_DIR_NAME |
| 366 if self._alternate_upload_dir: | 360 if self._alternate_upload_dir: |
| 367 dest_dir_name = self._alternate_upload_dir | 361 dest_dir_name = self._alternate_upload_dir |
| 368 | 362 |
| 369 self.gs.upload_dir_contents( | 363 self.gs.upload_dir_contents( |
| 370 LOCAL_PLAYBACK_ROOT_DIR, dest_dir=dest_dir_name, | 364 self._local_skp_dir, dest_dir=dest_dir_name, |
| 371 upload_if=gs_utils.GSUtils.UploadIf.IF_MODIFIED, | 365 upload_if=gs_utils.GSUtils.UploadIf.IF_MODIFIED, |
| 372 predefined_acl=GS_PREDEFINED_ACL, | 366 predefined_acl=GS_PREDEFINED_ACL, |
| 373 fine_grained_acl_list=GS_FINE_GRAINED_ACL_LIST) | 367 fine_grained_acl_list=GS_FINE_GRAINED_ACL_LIST) |
| 374 | 368 |
| 375 print '\n\n=======New SKPs have been uploaded to %s =======\n\n' % ( | 369 print '\n\n=======New SKPs have been uploaded to %s =======\n\n' % ( |
| 376 posixpath.join(self.gs.target_name(), dest_dir_name, | 370 posixpath.join(self.gs.target_name(), dest_dir_name, |
| 377 SKPICTURES_DIR_NAME)) | 371 SKPICTURES_DIR_NAME)) |
| 378 | 372 |
| 379 else: | 373 else: |
| 380 print '\n\n=======Not Uploading to %s=======\n\n' % self.gs.target_type() | 374 print '\n\n=======Not Uploading to %s=======\n\n' % self.gs.target_type() |
| 381 print 'Generated resources are available in %s\n\n' % ( | 375 print 'Generated resources are available in %s\n\n' % ( |
| 382 LOCAL_PLAYBACK_ROOT_DIR) | 376 self._local_skp_dir) |
| 383 | 377 |
| 384 if self._upload_to_partner_bucket: | 378 if self._upload_to_partner_bucket: |
| 385 print '\n\n=======Uploading to Partner bucket %s =======\n\n' % ( | 379 print '\n\n=======Uploading to Partner bucket %s =======\n\n' % ( |
| 386 PARTNERS_GS_BUCKET) | 380 PARTNERS_GS_BUCKET) |
| 387 partner_gs = GoogleStorageDataStore(PARTNERS_GS_BUCKET) | 381 partner_gs = GoogleStorageDataStore(PARTNERS_GS_BUCKET) |
| 388 partner_gs.delete_path(SKPICTURES_DIR_NAME) | 382 partner_gs.delete_path(SKPICTURES_DIR_NAME) |
| 383 print 'Uploading %s to %s' % (self._local_skp_dir, SKPICTURES_DIR_NAME) |
| 389 partner_gs.upload_dir_contents( | 384 partner_gs.upload_dir_contents( |
| 390 os.path.join(LOCAL_PLAYBACK_ROOT_DIR, SKPICTURES_DIR_NAME), | 385 self._local_skp_dir, |
| 391 dest_dir=SKPICTURES_DIR_NAME, | 386 dest_dir=SKPICTURES_DIR_NAME, |
| 392 upload_if=gs_utils.GSUtils.UploadIf.IF_MODIFIED) | 387 upload_if=gs_utils.GSUtils.UploadIf.IF_MODIFIED) |
| 393 print '\n\n=======New SKPs have been uploaded to %s =======\n\n' % ( | 388 print '\n\n=======New SKPs have been uploaded to %s =======\n\n' % ( |
| 394 posixpath.join(partner_gs.target_name(), SKPICTURES_DIR_NAME)) | 389 posixpath.join(partner_gs.target_name(), SKPICTURES_DIR_NAME)) |
| 395 | 390 |
| 396 return 0 | 391 return 0 |
| 397 | 392 |
| 398 def _GetSkiaSkpFileName(self, page_set): | 393 def _GetSkiaSkpFileName(self, page_set): |
| 399 """Returns the SKP file name for Skia page sets.""" | 394 """Returns the SKP file name for Skia page sets.""" |
| 400 # /path/to/skia_yahooanswers_desktop.py -> skia_yahooanswers_desktop.py | 395 # /path/to/skia_yahooanswers_desktop.py -> skia_yahooanswers_desktop.py |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 '--skia_tools is specified then the debugger is not run.', | 593 '--skia_tools is specified then the debugger is not run.', |
| 599 default=False) | 594 default=False) |
| 600 option_parser.add_option( | 595 option_parser.add_option( |
| 601 '', '--skp_prefix', | 596 '', '--skp_prefix', |
| 602 help='Prefix to add to the names of generated SKPs.', | 597 help='Prefix to add to the names of generated SKPs.', |
| 603 default=None) | 598 default=None) |
| 604 options, unused_args = option_parser.parse_args() | 599 options, unused_args = option_parser.parse_args() |
| 605 | 600 |
| 606 playback = SkPicturePlayback(options) | 601 playback = SkPicturePlayback(options) |
| 607 sys.exit(playback.Run()) | 602 sys.exit(playback.Run()) |
| OLD | NEW |