| OLD | NEW |
| 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 Loading... |
| 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)) |
| OLD | NEW |