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 os |
| 6 import re | |
| 6 | 7 |
| 7 from app_yaml_helper import AppYamlHelper | 8 from app_yaml_helper import AppYamlHelper |
| 8 | 9 |
| 9 def GetAppVersion(): | 10 def GetAppVersion(): |
| 10 if 'CURRENT_VERSION_ID' in os.environ: | 11 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 # The version ID looks like 2-0-25.36712548 or on the backend |
| 12 return os.environ['CURRENT_VERSION_ID'].split('.', 1)[0] | 13 # backend_name:2-0-25.23982345. We only want the 2-0-25. |
|
方觉(Fang Jue)
2013/08/14 01:47:42
Backend's version ID will look like <backend-name>
| |
| 14 return re.match( | |
| 15 r'(?:[_\w-]+:)?(\d+-\d+-\d+)\.\d+$', | |
| 16 os.environ['CURRENT_VERSION_ID']).group(1) | |
| 13 # Not running on appengine, get it from the app.yaml file ourselves. | 17 # 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') | 18 app_yaml_path = os.path.join(os.path.split(__file__)[0], 'app.yaml') |
| 15 with open(app_yaml_path, 'r') as app_yaml: | 19 with open(app_yaml_path, 'r') as app_yaml: |
| 16 return AppYamlHelper.ExtractVersion(app_yaml.read()) | 20 return AppYamlHelper.ExtractVersion(app_yaml.read()) |
| 17 | 21 |
| 18 def IsDevServer(): | 22 def IsDevServer(): |
| 19 return os.environ.get('SERVER_SOFTWARE', '').find('Development') == 0 | 23 return os.environ.get('SERVER_SOFTWARE', '').find('Development') == 0 |
| 20 | 24 |
| 21 # 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, |
| 22 # 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. |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 db._store.pop(key, None) | 268 db._store.pop(key, None) |
| 265 return _RPC() | 269 return _RPC() |
| 266 | 270 |
| 267 @staticmethod | 271 @staticmethod |
| 268 def put_async(value): | 272 def put_async(value): |
| 269 db._store[value.key] = value | 273 db._store[value.key] = value |
| 270 return _RPC() | 274 return _RPC() |
| 271 | 275 |
| 272 class BlobReferenceProperty(object): | 276 class BlobReferenceProperty(object): |
| 273 pass | 277 pass |
| OLD | NEW |