Chromium Code Reviews| 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 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.app_identity as app_identity |
| 22 import google.appengine.ext.blobstore as blobstore | |
|
ahernandez
2014/09/15 23:58:02
Is there a reason why this import was moved up?
Ken Rockot(use gerrit already)
2014/09/16 00:24:31
Alphabetical ordering makes me happy
ahernandez
2014/09/16 00:28:53
Shouldn't any imports prefixed with google.appengi
Ken Rockot(use gerrit already)
2014/09/16 00:31:19
Ludicrous! Yeah, you're right. I the "ext/api" bit
| |
| 22 import google.appengine.api.files as files | 23 import google.appengine.api.files as files |
| 23 import google.appengine.api.logservice as logservice | 24 import google.appengine.api.logservice as logservice |
| 24 import google.appengine.api.memcache as memcache | 25 import google.appengine.api.memcache as memcache |
| 26 import google.appengine.api.taskqueue as taskqueue | |
| 25 import google.appengine.api.urlfetch as urlfetch | 27 import google.appengine.api.urlfetch as urlfetch |
| 26 import google.appengine.ext.blobstore as blobstore | |
| 27 from google.appengine.ext.blobstore.blobstore import BlobReferenceProperty | 28 from google.appengine.ext.blobstore.blobstore import BlobReferenceProperty |
| 28 import google.appengine.ext.db as db | 29 import google.appengine.ext.db as db |
| 29 import webapp2 | 30 import webapp2 |
| 30 except ImportError: | 31 except ImportError: |
| 31 import re | 32 import re |
| 32 from StringIO import StringIO | 33 from StringIO import StringIO |
| 33 | 34 |
| 34 FAKE_URL_FETCHER_CONFIGURATION = None | 35 FAKE_URL_FETCHER_CONFIGURATION = None |
| 35 | 36 |
| 36 def ConfigureFakeUrlFetch(configuration): | 37 def ConfigureFakeUrlFetch(configuration): |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 db._store.pop(key, None) | 269 db._store.pop(key, None) |
| 269 return _RPC() | 270 return _RPC() |
| 270 | 271 |
| 271 @staticmethod | 272 @staticmethod |
| 272 def put_async(value): | 273 def put_async(value): |
| 273 db._store[value.key] = value | 274 db._store[value.key] = value |
| 274 return _RPC() | 275 return _RPC() |
| 275 | 276 |
| 276 class BlobReferenceProperty(object): | 277 class BlobReferenceProperty(object): |
| 277 pass | 278 pass |
| 279 | |
| 280 class FakeTaskQueue(object): | |
| 281 class Task(object): | |
| 282 def __init__(self, url=None, params={}): | |
| 283 pass | |
| 284 | |
| 285 class Queue(object): | |
| 286 def __init__(self, name='default'): | |
| 287 pass | |
| 288 | |
| 289 def add(self, task): | |
| 290 return _RPC() | |
| 291 | |
| 292 def purge(self): | |
| 293 return _RPC() | |
| 294 | |
| 295 taskqueue = FakeTaskQueue() | |
| OLD | NEW |