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 from StringIO import StringIO | 7 from StringIO import StringIO |
8 | 8 |
9 from appengine_blobstore import AppEngineBlobstore, BLOBSTORE_GITHUB | 9 from appengine_blobstore import AppEngineBlobstore, BLOBSTORE_GITHUB |
10 from appengine_url_fetcher import AppEngineUrlFetcher | 10 from appengine_url_fetcher import AppEngineUrlFetcher |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 122 |
123 def _ReadFile(self, path): | 123 def _ReadFile(self, path): |
124 try: | 124 try: |
125 zip_file = self._zip_file.Get() | 125 zip_file = self._zip_file.Get() |
126 except Exception as e: | 126 except Exception as e: |
127 logging.error('Github ReadFile error: %s' % e) | 127 logging.error('Github ReadFile error: %s' % e) |
128 return '' | 128 return '' |
129 if zip_file is None: | 129 if zip_file is None: |
130 logging.error('Bad github zip file.') | 130 logging.error('Bad github zip file.') |
131 return '' | 131 return '' |
132 prefix = zip_file.namelist()[0][:-1] | 132 prefix = zip_file.namelist()[0] |
133 return zip_file.read(prefix + path) | 133 return zip_file.read(prefix + path) |
134 | 134 |
135 def _ListDir(self, path): | 135 def _ListDir(self, path): |
136 try: | 136 try: |
137 zip_file = self._zip_file.Get() | 137 zip_file = self._zip_file.Get() |
138 except Exception as e: | 138 except Exception as e: |
139 logging.error('Github ListDir error: %s' % e) | 139 logging.error('Github ListDir error: %s' % e) |
140 return [] | 140 return [] |
141 if zip_file is None: | 141 if zip_file is None: |
142 logging.error('Bad github zip file.') | 142 logging.error('Bad github zip file.') |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |