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 | |
6 | |
7 from app_yaml_helper import AppYamlHelper | |
8 | |
9 def GetAppVersion(): | |
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 | |
18 def IsDeadlineExceededError(error): | 5 def IsDeadlineExceededError(error): |
19 '''A general way of determining whether |error| is a DeadlineExceededError, | 6 '''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 | 7 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: | 8 handle them all the same way. For more info see: |
22 https://developers.google.com/appengine/articles/deadlineexceedederrors | 9 https://developers.google.com/appengine/articles/deadlineexceedederrors |
23 ''' | 10 ''' |
24 return type(error).__name__ == 'DeadlineExceededError' | 11 return type(error).__name__ == 'DeadlineExceededError' |
25 | 12 |
| 13 |
26 def IsDownloadError(error): | 14 def IsDownloadError(error): |
27 return type(error).__name__ == 'DownloadError' | 15 return type(error).__name__ == 'DownloadError' |
28 | 16 |
| 17 |
29 # 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, |
30 # 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. |
31 try: | 20 try: |
32 import google.appengine.api.files as files | 21 import google.appengine.api.files as files |
33 import google.appengine.api.logservice as logservice | 22 import google.appengine.api.logservice as logservice |
34 import google.appengine.api.memcache as memcache | 23 import google.appengine.api.memcache as memcache |
35 import google.appengine.api.urlfetch as urlfetch | 24 import google.appengine.api.urlfetch as urlfetch |
36 import google.appengine.ext.blobstore as blobstore | 25 import google.appengine.ext.blobstore as blobstore |
37 from google.appengine.ext.blobstore.blobstore import BlobReferenceProperty | 26 from google.appengine.ext.blobstore.blobstore import BlobReferenceProperty |
38 import google.appengine.ext.db as db | 27 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) | 261 db._store.pop(key, None) |
273 return _RPC() | 262 return _RPC() |
274 | 263 |
275 @staticmethod | 264 @staticmethod |
276 def put_async(value): | 265 def put_async(value): |
277 db._store[value.key] = value | 266 db._store[value.key] = value |
278 return _RPC() | 267 return _RPC() |
279 | 268 |
280 class BlobReferenceProperty(object): | 269 class BlobReferenceProperty(object): |
281 pass | 270 pass |
OLD | NEW |