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

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

Issue 491653002: Docserver: Use GitilesFileSystem instead of SubversionFileSystem (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
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 def IsDeadlineExceededError(error): 5 def IsDeadlineExceededError(error):
6 '''A general way of determining whether |error| is a DeadlineExceededError, 6 '''A general way of determining whether |error| is a DeadlineExceededError,
7 since there are 3 different types thrown by AppEngine and we might as well 7 since there are 3 different types thrown by AppEngine and we might as well
8 handle them all the same way. For more info see: 8 handle them all the same way. For more info see:
9 https://developers.google.com/appengine/articles/deadlineexceedederrors 9 https://developers.google.com/appengine/articles/deadlineexceedederrors
10 ''' 10 '''
11 return type(error).__name__ == 'DeadlineExceededError' 11 return type(error).__name__ == 'DeadlineExceededError'
12 12
13 13
14 def IsDownloadError(error): 14 def IsDownloadError(error):
15 return type(error).__name__ == 'DownloadError' 15 return type(error).__name__ == 'DownloadError'
16 16
17 17
18 # This will attempt to import the actual App Engine modules, and if it fails, 18 # This will attempt to import the actual App Engine modules, and if it fails,
19 # they will be replaced with fake modules. This is useful during testing. 19 # they will be replaced with fake modules. This is useful during testing.
20 try: 20 try:
21 import google.appengine.api.app_identity as app_identity
21 import google.appengine.api.files as files 22 import google.appengine.api.files as files
22 import google.appengine.api.logservice as logservice 23 import google.appengine.api.logservice as logservice
23 import google.appengine.api.memcache as memcache 24 import google.appengine.api.memcache as memcache
24 import google.appengine.api.urlfetch as urlfetch 25 import google.appengine.api.urlfetch as urlfetch
25 import google.appengine.ext.blobstore as blobstore 26 import google.appengine.ext.blobstore as blobstore
26 from google.appengine.ext.blobstore.blobstore import BlobReferenceProperty 27 from google.appengine.ext.blobstore.blobstore import BlobReferenceProperty
27 import google.appengine.ext.db as db 28 import google.appengine.ext.db as db
28 import webapp2 29 import webapp2
29 except ImportError: 30 except ImportError:
30 import re 31 import re
(...skipping 23 matching lines...) Expand all
54 class _RPC(object): 55 class _RPC(object):
55 def __init__(self, result=None): 56 def __init__(self, result=None):
56 self.result = result 57 self.result = result
57 58
58 def get_result(self): 59 def get_result(self):
59 return self.result 60 return self.result
60 61
61 def wait(self): 62 def wait(self):
62 pass 63 pass
63 64
65 class FakeAppIdentity(object):
66 """A fake app_identity module that returns no access tokens."""
67 def get_access_token(self, scope):
68 return (None, None)
69 app_identity = FakeAppIdentity()
70
64 class FakeUrlFetch(object): 71 class FakeUrlFetch(object):
65 """A fake urlfetch module that uses the current 72 """A fake urlfetch module that uses the current
66 |FAKE_URL_FETCHER_CONFIGURATION| to map urls to fake fetchers. 73 |FAKE_URL_FETCHER_CONFIGURATION| to map urls to fake fetchers.
67 """ 74 """
68 class DownloadError(Exception): 75 class DownloadError(Exception):
69 pass 76 pass
70 77
71 class _Response(object): 78 class _Response(object):
72 def __init__(self, content): 79 def __init__(self, content):
73 self.content = content 80 self.content = content
74 self.headers = {'Content-Type': 'none'} 81 self.headers = {'Content-Type': 'none'}
75 self.status_code = 200 82 self.status_code = 200
76 83
77 def fetch(self, url, **kwargs): 84 def fetch(self, url, **kwargs):
78 url = url.split('?', 1)[0] 85 url = url.split('?', 1)[0]
79 response = self._Response(_GetConfiguration(url).fetch(url)) 86 response = self._Response(_GetConfiguration(url).fetch(url))
80 if response.content is None: 87 if response.content is None:
81 response.status_code = 404 88 response.status_code = 404
82 return response 89 return response
83 90
84 def create_rpc(self): 91 def create_rpc(self, **kwargs):
85 return _RPC() 92 return _RPC()
86 93
87 def make_fetch_call(self, rpc, url, **kwargs): 94 def make_fetch_call(self, rpc, url, **kwargs):
88 rpc.result = self.fetch(url) 95 rpc.result = self.fetch(url)
89 urlfetch = FakeUrlFetch() 96 urlfetch = FakeUrlFetch()
90 97
91 _BLOBS = {} 98 _BLOBS = {}
92 class FakeBlobstore(object): 99 class FakeBlobstore(object):
93 class BlobNotFoundError(Exception): 100 class BlobNotFoundError(Exception):
94 pass 101 pass
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 db._store.pop(key, None) 268 db._store.pop(key, None)
262 return _RPC() 269 return _RPC()
263 270
264 @staticmethod 271 @staticmethod
265 def put_async(value): 272 def put_async(value):
266 db._store[value.key] = value 273 db._store[value.key] = value
267 return _RPC() 274 return _RPC()
268 275
269 class BlobReferenceProperty(object): 276 class BlobReferenceProperty(object):
270 pass 277 pass
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698