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

Side by Side Diff: appengine/isolate/config.py

Issue 1708283003: isolateserver: add checkbox to enable ts_mon (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: Created 4 years, 10 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
OLDNEW
1 # Copyright 2013 The Swarming Authors. All rights reserved. 1 # Copyright 2013 The Swarming Authors. All rights reserved.
2 # Use of this source code is governed by the Apache v2.0 license that can be 2 # Use of this source code is governed by the Apache v2.0 license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Instance specific settings.""" 5 """Instance specific settings."""
6 6
7 import os 7 import os
8 8
9 from google.appengine.api import app_identity 9 from google.appengine.api import app_identity
10 from google.appengine.api import modules 10 from google.appengine.api import modules
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 # id to inject into pages if applicable. 48 # id to inject into pages if applicable.
49 google_analytics = ndb.StringProperty(indexed=False, default='') 49 google_analytics = ndb.StringProperty(indexed=False, default='')
50 50
51 # Enable ts_mon based monitoring. 51 # Enable ts_mon based monitoring.
52 enable_ts_monitoring = ndb.BooleanProperty(indexed=False, default=False) 52 enable_ts_monitoring = ndb.BooleanProperty(indexed=False, default=False)
53 53
54 def set_defaults(self): 54 def set_defaults(self):
55 self.global_secret = os.urandom(16) 55 self.global_secret = os.urandom(16)
56 self.gs_bucket = app_identity.get_application_id() 56 self.gs_bucket = app_identity.get_application_id()
57 57
58 @classmethod
M-A Ruel 2016/02/19 02:44:40 This code belongs to the frontend in my opinion, n
Sergey Berezin 2016/02/19 20:35:32 IMHO, keeping the type conversion closer to the de
M-A Ruel 2016/02/19 20:37:26 Yes but this function is purely related to form li
Sergey Berezin 2016/02/19 20:46:51 OK, done.
59 def cast_to_type(cls, param_name, value):
60 """Convert parameter's value to its type.
61
62 The intended use is to convert strings from HTTP request to the
63 appropriate parameter's type.
64 """
65 def to_bool(value):
66 if type(value) is bool:
67 return value
68 return {'True': True, 'False': False}.get(value, False)
69
70 def to_str(value):
71 return str(value)
72
73 cast = {
74 'enable_ts_monitoring': to_bool,
75 }.get(param_name, to_str)
76 return cast(value)
77
58 78
59 def settings(fresh=False): 79 def settings(fresh=False):
60 """Loads GlobalConfig or a default one if not present. 80 """Loads GlobalConfig or a default one if not present.
61 81
62 If fresh=True, a full fetch from NDB is done. 82 If fresh=True, a full fetch from NDB is done.
63 """ 83 """
64 if fresh: 84 if fresh:
65 GlobalConfig.clear_cache() 85 GlobalConfig.clear_cache()
66 return GlobalConfig.cached() 86 return GlobalConfig.cached()
67 87
68 88
69 def get_local_dev_server_host(): 89 def get_local_dev_server_host():
70 """Returns 'hostname:port' for a default module on a local dev server.""" 90 """Returns 'hostname:port' for a default module on a local dev server."""
71 assert utils.is_local_dev_server() 91 assert utils.is_local_dev_server()
72 return modules.get_hostname(module='default') 92 return modules.get_hostname(module='default')
73 93
74 94
75 def warmup(): 95 def warmup():
76 """Precaches configuration in local memory, to be called from warmup handler. 96 """Precaches configuration in local memory, to be called from warmup handler.
77 97
78 This call is optional. Everything works even if 'warmup' is never called. 98 This call is optional. Everything works even if 'warmup' is never called.
79 """ 99 """
80 settings() 100 settings()
81 utils.get_task_queue_host() 101 utils.get_task_queue_host()
82 utils.get_app_version() 102 utils.get_app_version()
OLDNEW
« no previous file with comments | « no previous file | appengine/isolate/handlers_frontend.py » ('j') | appengine/isolate/handlers_frontend.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698