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

Unified Diff: tools/chrome_remote_control/chrome_remote_control/page_set.py

Issue 10914237: Port perf.py's _LoginToGoogleAccount to chrome_remote_control (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
Index: tools/chrome_remote_control/chrome_remote_control/page_set.py
diff --git a/tools/chrome_remote_control/chrome_remote_control/page_set.py b/tools/chrome_remote_control/chrome_remote_control/page_set.py
index 02d121128962ceb4fc81ffcae8be312d197f2646..94d4ca2c29d223615b2bbe2aa4a53c49bd3ef82d 100644
--- a/tools/chrome_remote_control/chrome_remote_control/page_set.py
+++ b/tools/chrome_remote_control/chrome_remote_control/page_set.py
@@ -3,6 +3,7 @@
# found in the LICENSE file.
import json
import urlparse
+import os
class Page(object):
def __init__(self, url, attributes=None):
@@ -24,9 +25,11 @@ class Page(object):
return self.url
class PageSet(object):
- def __init__(self, description='', file_path=''):
+ def __init__(self, description='', file_path='',
+ credentials_path='credentials.json'):
nduca 2012/10/02 18:02:10 can we just default to None, and assume no credent
hartmanng 2012/10/02 20:18:16 Done.
self.description = description
self.file_path = file_path
+ self.credentials_path = credentials_path
self.pages = []
@classmethod
@@ -36,9 +39,19 @@ class PageSet(object):
data = json.loads(contents)
return cls.FromDict(data, file_path)
+ @staticmethod
+ def GetCredentialsPath(data, file_path):
nduca 2012/10/02 18:02:10 this bit i dont quite get... why are you computing
hartmanng 2012/10/02 20:18:16 Done.
+ credentials_path = os.path.join(os.path.dirname(file_path),
+ 'credentials.json')
+ if 'credentials_path' in data:
+ credentials_path = os.path.join(os.path.dirname(file_path),
+ data['credentials_path'])
+ return credentials_path
+
@classmethod
def FromDict(cls, data, file_path=''):
- page_set = cls(data['description'], file_path)
+ credentials_path = cls.GetCredentialsPath(data, file_path)
+ page_set = cls(data['description'], file_path, credentials_path)
nduca 2012/10/02 18:02:10 if you set credentials path to be the fully qualif
hartmanng 2012/10/02 20:18:16 Done.
for page_attributes in data['pages']:
url = page_attributes.pop('url')
page = Page(url, page_attributes)

Powered by Google App Engine
This is Rietveld 408576698