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

Side by Side Diff: chrome/common/extensions/docs/server2/gitiles_file_system.py

Issue 639773006: Docserver: Log the Gitiles access token so that it can be re-used in (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 unified diff | Download patch
« no previous file with comments | « chrome/common/extensions/docs/server2/cron.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 4
5 5
6 from base64 import b64decode 6 from base64 import b64decode
7 from itertools import izip 7 from itertools import izip
8 import json 8 import json
9 import logging 9 import logging
10 import posixpath 10 import posixpath
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 ''' 46 '''
47 tree = _ParseGitilesJson(json_data) 47 tree = _ParseGitilesJson(json_data)
48 return StatInfo(tree['id'], 48 return StatInfo(tree['id'],
49 dict((e['name'], e['id']) for e in tree['entries'])) 49 dict((e['name'], e['id']) for e in tree['entries']))
50 50
51 51
52 class GitilesFileSystem(FileSystem): 52 class GitilesFileSystem(FileSystem):
53 '''Class to fetch filesystem data from the Chromium project's gitiles 53 '''Class to fetch filesystem data from the Chromium project's gitiles
54 service. 54 service.
55 ''' 55 '''
56 @staticmethod 56 _logged_tokens = set()
57 def Create(branch='master', commit=None): 57
58 @classmethod
59 def Create(cls, branch='master', commit=None):
58 token, _ = app_identity.get_access_token(GITILES_OAUTH2_SCOPE) 60 token, _ = app_identity.get_access_token(GITILES_OAUTH2_SCOPE)
61
62 # Log the access token (once per token) so that it can be sneakily re-used
63 # in development.
64 if token not in cls._logged_tokens:
65 logging.info('Got token %s for scope %s' % (token, GITILES_OAUTH2_SCOPE))
66 cls._logged_tokens.add(token)
67
59 path_prefix = '' if token is None else _AUTH_PATH_PREFIX 68 path_prefix = '' if token is None else _AUTH_PATH_PREFIX
60 if commit: 69 if commit:
61 base_url = '%s%s/%s/%s' % ( 70 base_url = '%s%s/%s/%s' % (
62 GITILES_BASE, path_prefix, GITILES_SRC_ROOT, commit) 71 GITILES_BASE, path_prefix, GITILES_SRC_ROOT, commit)
63 elif branch is 'master': 72 elif branch is 'master':
64 base_url = '%s%s/%s/master' % ( 73 base_url = '%s%s/%s/master' % (
65 GITILES_BASE, path_prefix, GITILES_SRC_ROOT) 74 GITILES_BASE, path_prefix, GITILES_SRC_ROOT)
66 else: 75 else:
67 base_url = '%s%s/%s/%s/%s' % ( 76 base_url = '%s%s/%s/%s/%s' % (
68 GITILES_BASE, path_prefix, GITILES_SRC_ROOT, 77 GITILES_BASE, path_prefix, GITILES_SRC_ROOT,
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 234
226 def GetIdentity(self): 235 def GetIdentity(self):
227 # NOTE: Do not use commit information to create the string identity. 236 # NOTE: Do not use commit information to create the string identity.
228 # Doing so will mess up caching. 237 # Doing so will mess up caching.
229 if self._commit is None and self._branch != 'master': 238 if self._commit is None and self._branch != 'master':
230 str_id = '%s/%s/%s/%s' % ( 239 str_id = '%s/%s/%s/%s' % (
231 GITILES_BASE, GITILES_SRC_ROOT, GITILES_BRANCHES_PATH, self._branch) 240 GITILES_BASE, GITILES_SRC_ROOT, GITILES_BRANCHES_PATH, self._branch)
232 else: 241 else:
233 str_id = '%s/%s' % (GITILES_BASE, GITILES_SRC_ROOT) 242 str_id = '%s/%s' % (GITILES_BASE, GITILES_SRC_ROOT)
234 return '@'.join((self.__class__.__name__, StringIdentity(str_id))) 243 return '@'.join((self.__class__.__name__, StringIdentity(str_id)))
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/cron.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698