Adding the orphaned options pages to the navigation
[chromium-blink-merge.git] / chrome / common / extensions / docs / server2 / environment.py
blob4c8ae583f799fbdf4004dccad6ef32a9f93b4bc4
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.
5 import re
6 import os
7 import sys
9 from app_yaml_helper import AppYamlHelper
10 from third_party.json_schema_compiler.memoize import memoize
13 @memoize
14 def GetAppVersion():
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
22 # want the 2-0-25.
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
34 def IsDevServer():
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'