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

Side by Side Diff: tools/telemetry/telemetry/page/__init__.py

Issue 752883002: Revert of [Telemetry] Introduce shared_user_story_state for real. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 # Copyright 2012 The Chromium Authors. All rights reserved. 1 # Copyright 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 import inspect 4 import inspect
5 import logging 5 import logging
6 import os 6 import os
7 import urlparse 7 import urlparse
8 8
9 from telemetry import user_story 9 from telemetry import user_story
10 from telemetry.page import shared_page_state
11 from telemetry.util import cloud_storage 10 from telemetry.util import cloud_storage
12 from telemetry.util import path 11 from telemetry.util import path
13 12
14 13
15 def _UpdateCredentials(credentials_path): 14 def _UpdateCredentials(credentials_path):
16 # Attempt to download the credentials file. 15 # Attempt to download the credentials file.
17 try: 16 try:
18 cloud_storage.GetIfChanged(credentials_path) 17 cloud_storage.GetIfChanged(credentials_path)
19 except (cloud_storage.CredentialsError, cloud_storage.PermissionError, 18 except (cloud_storage.CredentialsError, cloud_storage.PermissionError,
20 cloud_storage.CloudStorageError) as e: 19 cloud_storage.CloudStorageError) as e:
21 logging.warning('Cannot retrieve credential file %s due to cloud storage ' 20 logging.warning('Cannot retrieve credential file %s due to cloud storage '
22 'error %s', credentials_path, str(e)) 21 'error %s', credentials_path, str(e))
23 22
24 23
25 class Page(user_story.UserStory): 24 class Page(user_story.UserStory):
26 def __init__(self, url, page_set=None, base_dir=None, name='', 25 def __init__(self, url, page_set=None, base_dir=None, name='',
27 credentials_path=None, labels=None): 26 credentials_path=None, labels=None):
28 super(Page, self).__init__(shared_page_state.SharedPageState, name, labels) 27 super(Page, self).__init__(name, labels)
29 self._url = url 28 self._url = url
30 self._page_set = page_set 29 self._page_set = page_set
31 # Default value of base_dir is the directory of the file that defines the 30 # Default value of base_dir is the directory of the file that defines the
32 # class of this page instance. 31 # class of this page instance.
33 if base_dir is None: 32 if base_dir is None:
34 base_dir = os.path.dirname(inspect.getfile(self.__class__)) 33 base_dir = os.path.dirname(inspect.getfile(self.__class__))
35 self._base_dir = base_dir 34 self._base_dir = base_dir
36 self._name = name 35 self._name = name
37 if credentials_path: 36 if credentials_path:
38 credentials_path = os.path.join(self._base_dir, credentials_path) 37 credentials_path = os.path.join(self._base_dir, credentials_path)
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 return self.name 192 return self.name
194 if not self.is_file: 193 if not self.is_file:
195 return self.url 194 return self.url
196 all_urls = [p.url.rstrip('/') for p in self.page_set if p.is_file] 195 all_urls = [p.url.rstrip('/') for p in self.page_set if p.is_file]
197 common_prefix = os.path.dirname(os.path.commonprefix(all_urls)) 196 common_prefix = os.path.dirname(os.path.commonprefix(all_urls))
198 return self.url[len(common_prefix):].strip('/') 197 return self.url[len(common_prefix):].strip('/')
199 198
200 @property 199 @property
201 def archive_path(self): 200 def archive_path(self):
202 return self.page_set.WprFilePathForPage(self) 201 return self.page_set.WprFilePathForPage(self)
OLDNEW
« no previous file with comments | « tools/telemetry/telemetry/core/browser_credentials.py ('k') | tools/telemetry/telemetry/page/page_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698