| Index: tools/telemetry/telemetry/user_story/user_story_runner.py
|
| diff --git a/tools/telemetry/telemetry/user_story/user_story_runner.py b/tools/telemetry/telemetry/user_story/user_story_runner.py
|
| index 0ec2b548bc352c57d72eb3dea35dd5e20ef52cb0..4eb547b7c7be2e81c134f4520fe4b6fc360a42f8 100644
|
| --- a/tools/telemetry/telemetry/user_story/user_story_runner.py
|
| +++ b/tools/telemetry/telemetry/user_story/user_story_runner.py
|
| @@ -9,6 +9,7 @@
|
| import sys
|
| import time
|
|
|
| +from telemetry import decorators
|
| from telemetry import page as page_module
|
| from telemetry.core import exceptions
|
| from telemetry.core import wpr_modes
|
| @@ -19,6 +20,7 @@
|
| from telemetry.user_story import user_story_filter
|
| from telemetry.user_story import user_story_set as user_story_set_module
|
| from telemetry.util import cloud_storage
|
| +from telemetry.util import exception_formatter
|
| from telemetry.value import failure
|
| from telemetry.value import skip
|
|
|
| @@ -114,6 +116,28 @@
|
| exception_formatter.PrintFormattedException(
|
| msg='Exception from DidRunUserStory: ')
|
|
|
| +@decorators.Cache
|
| +def _UpdateUserStoryArchivesIfChanged(user_story_set):
|
| + # Scan every serving directory for .sha1 files
|
| + # and download them from Cloud Storage. Assume all data is public.
|
| + all_serving_dirs = user_story_set.serving_dirs.copy()
|
| + # Add individual page dirs to all serving dirs.
|
| + for user_story in user_story_set:
|
| + if isinstance(user_story, page_module.Page) and user_story.is_file:
|
| + all_serving_dirs.add(user_story.serving_dir)
|
| + # Scan all serving dirs.
|
| + for serving_dir in all_serving_dirs:
|
| + if os.path.splitdrive(serving_dir)[1] == '/':
|
| + raise ValueError('Trying to serve root directory from HTTP server.')
|
| + for dirpath, _, filenames in os.walk(serving_dir):
|
| + for filename in filenames:
|
| + path, extension = os.path.splitext(
|
| + os.path.join(dirpath, filename))
|
| + if extension != '.sha1':
|
| + continue
|
| + cloud_storage.GetIfChanged(path, user_story_set.bucket)
|
| +
|
| +
|
| class UserStoryGroup(object):
|
| def __init__(self, shared_user_story_state_class):
|
| self._shared_user_story_state_class = shared_user_story_state_class
|
| @@ -183,10 +207,7 @@
|
|
|
| if (not finder_options.use_live_sites and user_story_set.bucket and
|
| finder_options.browser_options.wpr_mode != wpr_modes.WPR_RECORD):
|
| - serving_dirs = user_story_set.serving_dirs
|
| - for directory in serving_dirs:
|
| - cloud_storage.GetFilesInDirectoryIfChanged(directory,
|
| - user_story_set.bucket)
|
| + _UpdateUserStoryArchivesIfChanged(user_story_set)
|
| if not _UpdateAndCheckArchives(
|
| user_story_set.archive_data_file, user_story_set.wpr_archive_info,
|
| user_stories):
|
|
|