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 os |
6 | 6 |
| 7 from app_yaml_helper import AppYamlHelper |
| 8 |
7 def GetAppVersion(): | 9 def GetAppVersion(): |
8 if 'CURRENT_VERSION_ID' in os.environ: | 10 if 'CURRENT_VERSION_ID' in os.environ: |
9 # The version ID looks like 2-0-25.36712548, we only want the 2-0-25. | 11 # The version ID looks like 2-0-25.36712548, we only want the 2-0-25. |
10 return os.environ['CURRENT_VERSION_ID'].split('.', 1)[0] | 12 return os.environ['CURRENT_VERSION_ID'].split('.', 1)[0] |
11 # Not running on appengine, get it from the app.yaml file ourselves. We | 13 # Not running on appengine, get it from the app.yaml file ourselves. |
12 # could properly parse this using a yaml library but Python doesn't have | |
13 # one built in so whatevs. | |
14 version_key = 'version:' | |
15 app_yaml_path = os.path.join(os.path.split(__file__)[0], 'app.yaml') | 14 app_yaml_path = os.path.join(os.path.split(__file__)[0], 'app.yaml') |
16 with open(app_yaml_path, 'r') as app_yaml: | 15 with open(app_yaml_path, 'r') as app_yaml: |
17 version_line = [line for line in app_yaml.read().split('\n') | 16 return AppYamlHelper.ExtractVersion(app_yaml.read()) |
18 if line.startswith(version_key)][0] | |
19 return version_line[len(version_key):].strip() | |
20 | 17 |
21 def IsDevServer(): | 18 def IsDevServer(): |
22 return os.environ.get('SERVER_SOFTWARE', '').find('Development') == 0 | 19 return os.environ.get('SERVER_SOFTWARE', '').find('Development') == 0 |
23 | 20 |
24 # This will attempt to import the actual App Engine modules, and if it fails, | 21 # This will attempt to import the actual App Engine modules, and if it fails, |
25 # they will be replaced with fake modules. This is useful during testing. | 22 # they will be replaced with fake modules. This is useful during testing. |
26 try: | 23 try: |
27 import google.appengine.api.files as files | 24 import google.appengine.api.files as files |
28 import google.appengine.api.logservice as logservice | 25 import google.appengine.api.logservice as logservice |
29 import google.appengine.api.memcache as memcache | 26 import google.appengine.api.memcache as memcache |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 db._store.pop(key, None) | 264 db._store.pop(key, None) |
268 return _RPC() | 265 return _RPC() |
269 | 266 |
270 @staticmethod | 267 @staticmethod |
271 def put_async(value): | 268 def put_async(value): |
272 db._store[value.key] = value | 269 db._store[value.key] = value |
273 return _RPC() | 270 return _RPC() |
274 | 271 |
275 class BlobReferenceProperty(object): | 272 class BlobReferenceProperty(object): |
276 pass | 273 pass |
OLD | NEW |