OLD | NEW |
---|---|
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 re |
6 import os | 6 import os |
7 import sys | 7 import sys |
8 | 8 |
9 from app_yaml_helper import AppYamlHelper | 9 from app_yaml_helper import AppYamlHelper |
10 from third_party.json_schema_compiler.memoize import memoize | 10 from third_party.json_schema_compiler.memoize import memoize |
(...skipping 13 matching lines...) Expand all Loading... | |
24 # Not running on appengine, get it from the app.yaml file ourselves. | 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') | 25 app_yaml_path = os.path.join(os.path.split(__file__)[0], 'app.yaml') |
26 with open(app_yaml_path, 'r') as app_yaml: | 26 with open(app_yaml_path, 'r') as app_yaml: |
27 return AppYamlHelper.ExtractVersion(app_yaml.read()) | 27 return AppYamlHelper.ExtractVersion(app_yaml.read()) |
28 | 28 |
29 | 29 |
30 def _IsServerSoftware(name): | 30 def _IsServerSoftware(name): |
31 return os.environ.get('SERVER_SOFTWARE', '').find(name) == 0 | 31 return os.environ.get('SERVER_SOFTWARE', '').find(name) == 0 |
32 | 32 |
33 | 33 |
34 def IsComputeEngine(): | |
35 return _IsServerSoftware('Compute Engine') | |
Ken Rockot(use gerrit already)
2015/05/26 00:26:24
Not a real thing, but there were no obvious enviro
| |
36 | |
37 | |
34 def IsDevServer(): | 38 def IsDevServer(): |
35 return _IsServerSoftware('Development') | 39 return _IsServerSoftware('Development') |
36 | 40 |
37 | 41 |
38 def IsReleaseServer(): | 42 def IsReleaseServer(): |
39 return _IsServerSoftware('Google App Engine') | 43 return _IsServerSoftware('Google App Engine') |
40 | 44 |
41 | 45 |
42 def IsPreviewServer(): | 46 def IsPreviewServer(): |
43 return sys.argv and os.path.basename(sys.argv[0]) == 'preview.py' | 47 return sys.argv and os.path.basename(sys.argv[0]) == 'preview.py' |
48 | |
49 | |
50 def IsAppEngine(): | |
51 return IsDevServer() or IsReleaseServer() | |
52 | |
53 | |
54 def IsTest(): | |
55 return sys.argv and os.path.basename(sys.argv[0]).endswith('_test.py') | |
Ken Rockot(use gerrit already)
2015/05/26 00:26:24
Added this because it's no longer true that !IsApp
| |
56 | |
57 | |
58 class UnknownEnvironmentError(Exception): | |
59 pass | |
60 | |
OLD | NEW |