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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 self._username, self._password = (USERNAME, PASSWORD) | 93 self._username, self._password = (USERNAME, PASSWORD) |
94 | 94 |
95 self._url = url | 95 self._url = url |
96 self._fetcher = AppEngineUrlFetcher(url) | 96 self._fetcher = AppEngineUrlFetcher(url) |
97 self._blobstore = blobstore | 97 self._blobstore = blobstore |
98 self._stat_object_store = object_store_creator.Create(GithubFileSystem) | 98 self._stat_object_store = object_store_creator.Create(GithubFileSystem) |
99 self._version = None | 99 self._version = None |
100 self._GetZip(self.Stat(ZIP_KEY).version) | 100 self._GetZip(self.Stat(ZIP_KEY).version) |
101 | 101 |
102 def _GetZip(self, version): | 102 def _GetZip(self, version): |
103 blob = self._blobstore.Get(_MakeBlobstoreKey(version), | 103 try: |
104 blobstore.BLOBSTORE_GITHUB) | 104 blob = self._blobstore.Get(_MakeBlobstoreKey(version), |
105 blobstore.BLOBSTORE_GITHUB) | |
106 except: | |
Yoyo Zhou
2013/12/13 05:15:21
except SpecificTypeOfError: would be better.
not at google - send to devlin
2013/12/18 02:26:11
Done.
| |
107 self._zip_file = Future(value=None) | |
108 return | |
105 if blob is not None: | 109 if blob is not None: |
106 try: | 110 try: |
107 self._zip_file = Future(value=ZipFile(StringIO(blob))) | 111 self._zip_file = Future(value=ZipFile(StringIO(blob))) |
108 except BadZipfile as e: | 112 except BadZipfile as e: |
109 self._blobstore.Delete(_MakeBlobstoreKey(version), | 113 self._blobstore.Delete(_MakeBlobstoreKey(version), |
110 blobstore.BLOBSTORE_GITHUB) | 114 blobstore.BLOBSTORE_GITHUB) |
111 logging.error('Bad github zip file: %s' % e) | 115 logging.error('Bad github zip file: %s' % e) |
112 self._zip_file = Future(value=None) | 116 self._zip_file = Future(value=None) |
113 else: | 117 else: |
114 self._zip_file = Future( | 118 self._zip_file = Future( |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 self._stat_object_store.Set(path, version) | 203 self._stat_object_store.Set(path, version) |
200 return StatInfo(version) | 204 return StatInfo(version) |
201 except StandardError as e: | 205 except StandardError as e: |
202 logging.warning( | 206 logging.warning( |
203 ('%s: got invalid or unexpected JSON from github. Response status ' + | 207 ('%s: got invalid or unexpected JSON from github. Response status ' + |
204 'was %s, content %s') % (e, result.status_code, result.content)) | 208 'was %s, content %s') % (e, result.status_code, result.content)) |
205 return self._DefaultStat(path) | 209 return self._DefaultStat(path) |
206 | 210 |
207 def GetIdentity(self): | 211 def GetIdentity(self): |
208 return '%s@%s' % (self.__class__.__name__, StringIdentity(self._url)) | 212 return '%s@%s' % (self.__class__.__name__, StringIdentity(self._url)) |
OLD | NEW |