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 import os | 5 import re |
|
not at google - send to devlin
2014/05/23 19:14:29
will remove in next patchset.
| |
| 6 | 6 |
| 7 from app_yaml_helper import AppYamlHelper | |
| 8 | |
| 9 def GetAppVersion(): | |
|
not at google - send to devlin
2014/05/23 19:14:29
moved this into environment.py because it seemed m
| |
| 10 if 'CURRENT_VERSION_ID' in os.environ: | |
| 11 # The version ID looks like 2-0-25.36712548, we only want the 2-0-25. | |
| 12 return os.environ['CURRENT_VERSION_ID'].split('.', 1)[0] | |
| 13 # Not running on appengine, get it from the app.yaml file ourselves. | |
| 14 app_yaml_path = os.path.join(os.path.split(__file__)[0], 'app.yaml') | |
| 15 with open(app_yaml_path, 'r') as app_yaml: | |
| 16 return AppYamlHelper.ExtractVersion(app_yaml.read()) | |
| 17 | 7 |
| 18 def IsDeadlineExceededError(error): | 8 def IsDeadlineExceededError(error): |
| 19 '''A general way of determining whether |error| is a DeadlineExceededError, | 9 '''A general way of determining whether |error| is a DeadlineExceededError, |
| 20 since there are 3 different types thrown by AppEngine and we might as well | 10 since there are 3 different types thrown by AppEngine and we might as well |
| 21 handle them all the same way. For more info see: | 11 handle them all the same way. For more info see: |
| 22 https://developers.google.com/appengine/articles/deadlineexceedederrors | 12 https://developers.google.com/appengine/articles/deadlineexceedederrors |
| 23 ''' | 13 ''' |
| 24 return type(error).__name__ == 'DeadlineExceededError' | 14 return type(error).__name__ == 'DeadlineExceededError' |
| 25 | 15 |
| 16 | |
| 26 def IsDownloadError(error): | 17 def IsDownloadError(error): |
| 27 return type(error).__name__ == 'DownloadError' | 18 return type(error).__name__ == 'DownloadError' |
| 28 | 19 |
| 20 | |
| 21 def IsOverQuotaError(error): | |
|
not at google - send to devlin
2014/05/23 19:14:29
will remove in next patchset
| |
| 22 return type(error).__name__ == 'OverQuotaError' | |
| 23 | |
| 24 | |
| 29 # This will attempt to import the actual App Engine modules, and if it fails, | 25 # This will attempt to import the actual App Engine modules, and if it fails, |
| 30 # they will be replaced with fake modules. This is useful during testing. | 26 # they will be replaced with fake modules. This is useful during testing. |
| 31 try: | 27 try: |
| 32 import google.appengine.api.files as files | 28 import google.appengine.api.files as files |
| 33 import google.appengine.api.logservice as logservice | 29 import google.appengine.api.logservice as logservice |
| 34 import google.appengine.api.memcache as memcache | 30 import google.appengine.api.memcache as memcache |
| 35 import google.appengine.api.urlfetch as urlfetch | 31 import google.appengine.api.urlfetch as urlfetch |
| 36 import google.appengine.ext.blobstore as blobstore | 32 import google.appengine.ext.blobstore as blobstore |
| 37 from google.appengine.ext.blobstore.blobstore import BlobReferenceProperty | 33 from google.appengine.ext.blobstore.blobstore import BlobReferenceProperty |
| 38 import google.appengine.ext.db as db | 34 import google.appengine.ext.db as db |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 db._store.pop(key, None) | 268 db._store.pop(key, None) |
| 273 return _RPC() | 269 return _RPC() |
| 274 | 270 |
| 275 @staticmethod | 271 @staticmethod |
| 276 def put_async(value): | 272 def put_async(value): |
| 277 db._store[value.key] = value | 273 db._store[value.key] = value |
| 278 return _RPC() | 274 return _RPC() |
| 279 | 275 |
| 280 class BlobReferenceProperty(object): | 276 class BlobReferenceProperty(object): |
| 281 pass | 277 pass |
| OLD | NEW |