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

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

Issue 82433002: Docserver: Further refactoring to the new GithubFileSystem to make it update (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, fix test data Created 7 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 | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 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 4
5 import json 5 import json
6 import logging 6 import logging
7 import os 7 import os
8 from StringIO import StringIO 8 from StringIO import StringIO
9 9
10 import appengine_blobstore as blobstore 10 import appengine_blobstore as blobstore
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 logging.warning('Github authentication failed for %s, falling back to ' 188 logging.warning('Github authentication failed for %s, falling back to '
189 'unauthenticated.' % USERNAME) 189 'unauthenticated.' % USERNAME)
190 try: 190 try:
191 result = self._fetcher.Fetch('commits/HEAD') 191 result = self._fetcher.Fetch('commits/HEAD')
192 except urlfetch.DownloadError as e: 192 except urlfetch.DownloadError as e:
193 logging.warning('GithubFileSystem Stat: %s' % e) 193 logging.warning('GithubFileSystem Stat: %s' % e)
194 return self._DefaultStat(path) 194 return self._DefaultStat(path)
195 195
196 # Parse response JSON - but sometimes github gives us invalid JSON. 196 # Parse response JSON - but sometimes github gives us invalid JSON.
197 try: 197 try:
198 version = json.loads(result.content)['commit']['tree']['sha'] 198 version = json.loads(result.content)['commit']['sha']
199 self._stat_object_store.Set(path, version) 199 self._stat_object_store.Set(path, version)
200 return StatInfo(version) 200 return StatInfo(version)
201 except StandardError as e: 201 except StandardError as e:
202 logging.warning( 202 logging.warning(
203 ('%s: got invalid or unexpected JSON from github. Response status ' + 203 ('%s: got invalid or unexpected JSON from github. Response status ' +
204 'was %s, content %s') % (e, result.status_code, result.content)) 204 'was %s, content %s') % (e, result.status_code, result.content))
205 return self._DefaultStat(path) 205 return self._DefaultStat(path)
206 206
207 def GetIdentity(self): 207 def GetIdentity(self):
208 return '%s@%s' % (self.__class__.__name__, StringIdentity(self._url)) 208 return '%s@%s' % (self.__class__.__name__, StringIdentity(self._url))
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/file_system.py ('k') | chrome/common/extensions/docs/server2/new_github_file_system.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698