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

Unified Diff: tools/telemetry/telemetry/page/__init__.py

Issue 625123002: Make credential_path a page attribute instead of page_set attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert changes to path & path_unittest Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/telemetry/telemetry/core/util.py ('k') | tools/telemetry/telemetry/page/page_runner.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/page/__init__.py
diff --git a/tools/telemetry/telemetry/page/__init__.py b/tools/telemetry/telemetry/page/__init__.py
index 2435080a8460799d523cf35cc7ce8ecfade86dd5..4352e41ba0d82cda6e577333f0579fe75d77d97f 100644
--- a/tools/telemetry/telemetry/page/__init__.py
+++ b/tools/telemetry/telemetry/page/__init__.py
@@ -2,15 +2,28 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import inspect
+import logging
import os
import urlparse
from telemetry import user_story
+from telemetry.util import cloud_storage
+from telemetry.util import path
-class Page(user_story.UserStory):
+def _UpdateCredentials(credentials_path):
+ # Attempt to download the credentials file.
+ try:
+ cloud_storage.GetIfChanged(credentials_path)
+ except (cloud_storage.CredentialsError, cloud_storage.PermissionError,
+ cloud_storage.CloudStorageError) as e:
+ logging.warning('Cannot retrieve credential file %s due to cloud storage '
+ 'error %s', credentials_path, str(e))
+
- def __init__(self, url, page_set=None, base_dir=None, name=''):
+class Page(user_story.UserStory):
+ def __init__(self, url, page_set=None, base_dir=None, name='',
+ credentials_path=None):
super(Page, self).__init__(name)
self._url = url
self._page_set = page_set
@@ -20,7 +33,13 @@ class Page(user_story.UserStory):
base_dir = os.path.dirname(inspect.getfile(self.__class__))
self._base_dir = base_dir
self._name = name
-
+ if credentials_path:
+ credentials_path = os.path.join(self._base_dir, credentials_path)
+ _UpdateCredentials(credentials_path)
+ if not os.path.exists(credentials_path):
+ logging.error('Invalid credentials path: %s' % credentials_path)
+ credentials_path = None
+ self._credentials_path = credentials_path
# These attributes can be set dynamically by the page.
self.synthetic_delays = dict()
@@ -30,6 +49,10 @@ class Page(user_story.UserStory):
self.script_to_evaluate_on_commit = None
self._SchemeErrorCheck()
+ @property
+ def credentials_path(self):
+ return self._credentials_path
+
def _SchemeErrorCheck(self):
if not self._scheme:
raise ValueError('Must prepend the URL with scheme (e.g. file://)')
@@ -141,6 +164,10 @@ class Page(user_story.UserStory):
self._base_dir, parsed_url.netloc + parsed_url.path))
@property
+ def base_dir(self):
+ return self._base_dir
+
+ @property
def file_path_url(self):
"""Returns the file path, including the params, query, and fragment."""
assert self.is_file
« no previous file with comments | « tools/telemetry/telemetry/core/util.py ('k') | tools/telemetry/telemetry/page/page_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698