1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
9 from app_yaml_helper
import AppYamlHelper
10 from third_party
.json_schema_compiler
.memoize
import memoize
15 return GetAppVersionNonMemoized()
18 # This one is for running from tests, which memoization messes up.
19 def GetAppVersionNonMemoized():
20 if 'CURRENT_VERSION_ID' in os
.environ
:
21 # The version ID looks like 2-0-25.36712548 or 2-0-25.23/223; we only
23 return re
.compile('[./]').split(os
.environ
['CURRENT_VERSION_ID'])[0]
24 # Not running on appengine, get it from the app.yaml file ourselves.
25 app_yaml_path
= os
.path
.join(os
.path
.split(__file__
)[0], 'app.yaml')
26 with
open(app_yaml_path
, 'r') as app_yaml
:
27 return AppYamlHelper
.ExtractVersion(app_yaml
.read())
30 def _IsServerSoftware(name
):
31 return os
.environ
.get('SERVER_SOFTWARE', '').find(name
) == 0
35 return _IsServerSoftware('Development')
38 def IsReleaseServer():
39 return _IsServerSoftware('Google App Engine')
42 def IsPreviewServer():
43 return sys
.argv
and os
.path
.basename(sys
.argv
[0]) == 'preview.py'