Index: tools/telemetry/telemetry/page/page_set.py |
diff --git a/tools/telemetry/telemetry/page/page_set.py b/tools/telemetry/telemetry/page/page_set.py |
index 234e7b1a8e29655934c755707c93162c7c1aaed9..08009e821e852c4ca0b186b58d910073a93fb133 100644 |
--- a/tools/telemetry/telemetry/page/page_set.py |
+++ b/tools/telemetry/telemetry/page/page_set.py |
@@ -9,6 +9,13 @@ import os |
from telemetry.core import util |
from telemetry.page import page as page_module |
from telemetry.page import page_set_archive_info |
+from telemetry.page import cloud_storage |
+ |
+ |
+PUBLIC_BUCKET = cloud_storage.PUBLIC_BUCKET |
+PARTNER_BUCKET = cloud_storage.PARTNER_BUCKET |
+INTERNAL_BUCKET = cloud_storage.INTERNAL_BUCKET |
+ |
class PageSetError(Exception): |
pass |
@@ -18,7 +25,7 @@ class PageSet(object): |
def __init__(self, file_path=None, archive_data_file='', |
credentials_path=None, user_agent_type=None, |
make_javascript_deterministic=True, startup_url='', |
- serving_dirs=None): |
+ serving_dirs=None, privacy_bucket=None): |
# The default value of file_path is location of the file that define this |
# page set instance's class. |
if file_path is None: |
@@ -44,6 +51,11 @@ class PageSet(object): |
self.serving_dirs.add(os.path.realpath(sd)) |
else: |
self.serving_dirs.add(os.path.realpath(os.path.join(self.base_dir, sd))) |
+ if self._IsValidPrivacyBucket(privacy_bucket): |
+ self._privacy_bucket = privacy_bucket |
+ else: |
+ raise ValueError("Pageset privacy bucket %s is invalid" |
+ % privacy_bucket) |
tonyg
2014/06/09 22:02:37
nit: indentation is 2 spaces too deep. This may al
|
@classmethod |
def Name(cls): |
@@ -99,6 +111,14 @@ pages in %s must be in the form of def Run<...>(self, action_runner):""" |
% file_path) |
return page_set |
+ @staticmethod |
+ def _IsValidPrivacyBucket(bucket_name): |
+ if not bucket_name: |
+ return True |
+ if (bucket_name in [PUBLIC_BUCKET, PARTNER_BUCKET, INTERNAL_BUCKET]): |
+ return True |
+ return False |
+ |
@property |
def base_dir(self): |
if os.path.isfile(self.file_path): |
@@ -115,6 +135,10 @@ pages in %s must be in the form of def Run<...>(self, action_runner):""" |
os.path.join(self.base_dir, self.archive_data_file))) |
return self._wpr_archive_info |
+ @property |
+ def privacy_bucket(self): |
+ return self._privacy_bucket |
+ |
@wpr_archive_info.setter |
def wpr_archive_info(self, value): # pylint: disable=E0202 |
self._wpr_archive_info = value |