Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1221)

Side by Side Diff: chrome/common/extensions/docs/server2/environment.py

Issue 297963004: Docserver: Update app version parsing since AppEngine started including / (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 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 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 re
5 import os 6 import os
6 import sys 7 import sys
7 8
9 from app_yaml_helper import AppYamlHelper
10 from third_party.json_schema_compiler.memoize import memoize
11
12
13 @memoize
14 def GetAppVersion():
15 return GetAppVersionNonMemoized()
16
17
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())
28
8 29
9 def _IsServerSoftware(name): 30 def _IsServerSoftware(name):
10 return os.environ.get('SERVER_SOFTWARE', '').find(name) == 0 31 return os.environ.get('SERVER_SOFTWARE', '').find(name) == 0
11 32
12 33
13 def IsDevServer(): 34 def IsDevServer():
14 return _IsServerSoftware('Development') 35 return _IsServerSoftware('Development')
15 36
16 37
17 def IsReleaseServer(): 38 def IsReleaseServer():
18 return _IsServerSoftware('Google App Engine') 39 return _IsServerSoftware('Google App Engine')
19 40
20 41
21 def IsPreviewServer(): 42 def IsPreviewServer():
22 return sys.argv and os.path.basename(sys.argv[0]) == 'preview.py' 43 return sys.argv and os.path.basename(sys.argv[0]) == 'preview.py'
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/cron_servlet_test.py ('k') | chrome/common/extensions/docs/server2/environment_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698