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

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

Issue 14267024: Devserver: have a separate ObjectStore namespace (both memcache and datastore) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove _CheckVersions Created 7 years, 8 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 | 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 8
9 import appengine_blobstore as blobstore 9 import appengine_blobstore as blobstore
10 from appengine_wrappers import urlfetch 10 from appengine_wrappers import GetAppVersion, urlfetch
11 from file_system import FileSystem, StatInfo 11 from file_system import FileSystem, StatInfo
12 from future import Future 12 from future import Future
13 from object_store_creator import ObjectStoreCreator 13 from object_store_creator import ObjectStoreCreator
14 from StringIO import StringIO 14 from StringIO import StringIO
15 from zipfile import ZipFile, BadZipfile 15 from zipfile import ZipFile, BadZipfile
16 16
17 ZIP_KEY = 'zipball' 17 ZIP_KEY = 'zipball'
18 USERNAME = None 18 USERNAME = None
19 PASSWORD = None 19 PASSWORD = None
20 20
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 self._blobstore.Set(_MakeBlobstoreKey(self._key_to_set), 56 self._blobstore.Set(_MakeBlobstoreKey(self._key_to_set),
57 blob, 57 blob,
58 blobstore.BLOBSTORE_GITHUB) 58 blobstore.BLOBSTORE_GITHUB)
59 return return_zip 59 return return_zip
60 60
61 class GithubFileSystem(FileSystem): 61 class GithubFileSystem(FileSystem):
62 """FileSystem implementation which fetches resources from github. 62 """FileSystem implementation which fetches resources from github.
63 """ 63 """
64 def __init__(self, fetcher, blobstore): 64 def __init__(self, fetcher, blobstore):
65 self._fetcher = fetcher 65 self._fetcher = fetcher
66 self._stat_object_store = ObjectStoreCreator(GithubFileSystem).Create() 66 self._stat_object_store = (ObjectStoreCreator.SharedFactory(GetAppVersion())
67 .Create(GithubFileSystem).Create())
67 self._blobstore = blobstore 68 self._blobstore = blobstore
68 self._version = None 69 self._version = None
69 self._GetZip(self.Stat(ZIP_KEY).version) 70 self._GetZip(self.Stat(ZIP_KEY).version)
70 71
71 def _GetZip(self, version): 72 def _GetZip(self, version):
72 blob = self._blobstore.Get(_MakeBlobstoreKey(version), 73 blob = self._blobstore.Get(_MakeBlobstoreKey(version),
73 blobstore.BLOBSTORE_GITHUB) 74 blobstore.BLOBSTORE_GITHUB)
74 if blob is not None: 75 if blob is not None:
75 try: 76 try:
76 self._zip_file = Future(value=ZipFile(StringIO(blob))) 77 self._zip_file = Future(value=ZipFile(StringIO(blob)))
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 version = (json.loads(result.content).get('commit', {}) 162 version = (json.loads(result.content).get('commit', {})
162 .get('tree', {}) 163 .get('tree', {})
163 .get('sha', None)) 164 .get('sha', None))
164 # Check if the JSON was valid, and set to 0 if not. 165 # Check if the JSON was valid, and set to 0 if not.
165 if version is not None: 166 if version is not None:
166 self._stat_object_store.Set(path, version) 167 self._stat_object_store.Set(path, version)
167 else: 168 else:
168 logging.warning('Problem fetching commit hash from github.') 169 logging.warning('Problem fetching commit hash from github.')
169 return self._DefaultStat(path) 170 return self._DefaultStat(path)
170 return StatInfo(version) 171 return StatInfo(version)
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/file_system.py ('k') | chrome/common/extensions/docs/server2/intro_data_source.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698