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

Side by Side Diff: appengine/findit/handlers/config.py

Issue 2104113002: [Findit] Add settings for actions after culprits or suspects are identified. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@group_same_failures
Patch Set: Address chan's comments. Created 4 years, 5 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
« no previous file with comments | « no previous file | appengine/findit/handlers/test/config_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 """Handles requests to the findit config page.""" 5 """Handles requests to the findit config page."""
6 6
7 import json 7 import json
8 8
9 from common.base_handler import BaseHandler 9 from common.base_handler import BaseHandler
10 from common.base_handler import Permission 10 from common.base_handler import Permission
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 168
169 def _ValidateDownloadBuildDataSettings(settings): 169 def _ValidateDownloadBuildDataSettings(settings):
170 return (isinstance(settings, dict) and 170 return (isinstance(settings, dict) and
171 isinstance(settings.get('download_interval_seconds'), int) and 171 isinstance(settings.get('download_interval_seconds'), int) and
172 isinstance(settings.get( 172 isinstance(settings.get(
173 'memcache_master_download_expiration_seconds'), int) and 173 'memcache_master_download_expiration_seconds'), int) and
174 isinstance(settings.get('use_chrome_build_extract'), bool)) 174 isinstance(settings.get('use_chrome_build_extract'), bool))
175 175
176 176
177 def _ValidateActionSettings(settings):
178 return (isinstance(settings, dict) and
179 isinstance(settings.get('cr_notification_build_threshold'), int) and
180 isinstance(
181 settings.get('cr_notification_latency_limit_minutes'), int))
182
183
177 # Maps config properties to their validation functions. 184 # Maps config properties to their validation functions.
178 _CONFIG_VALIDATION_FUNCTIONS = { 185 _CONFIG_VALIDATION_FUNCTIONS = {
179 'steps_for_masters_rules': _ValidateMastersAndStepsRulesMapping, 186 'steps_for_masters_rules': _ValidateMastersAndStepsRulesMapping,
180 'builders_to_trybots': _ValidateTrybotMapping, 187 'builders_to_trybots': _ValidateTrybotMapping,
181 'try_job_settings': _ValidateTryJobSettings, 188 'try_job_settings': _ValidateTryJobSettings,
182 'swarming_settings': _ValidateSwarmingSettings, 189 'swarming_settings': _ValidateSwarmingSettings,
183 'download_build_data_settings': _ValidateDownloadBuildDataSettings 190 'download_build_data_settings': _ValidateDownloadBuildDataSettings,
191 'action_settings': _ValidateActionSettings,
184 } 192 }
185 193
186 194
187 def _ConfigurationDictIsValid(configuration_dict): 195 def _ConfigurationDictIsValid(configuration_dict):
188 """Checks that each configuration setting is properly formatted. 196 """Checks that each configuration setting is properly formatted.
189 197
190 Args: 198 Args:
191 configuration_dict: A dictionary expected to map configuration properties 199 configuration_dict: A dictionary expected to map configuration properties
192 by name to their intended settings. For example, 200 by name to their intended settings. For example,
193 201
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 'The requested version is invalid or not found.', 400) 244 'The requested version is invalid or not found.', 400)
237 245
238 latest_version = settings.GetLatestVersionNumber() 246 latest_version = settings.GetLatestVersionNumber()
239 247
240 data = { 248 data = {
241 'masters': waterfall_config.GetStepsForMastersRules(settings), 249 'masters': waterfall_config.GetStepsForMastersRules(settings),
242 'builders': settings.builders_to_trybots, 250 'builders': settings.builders_to_trybots,
243 'try_job_settings': settings.try_job_settings, 251 'try_job_settings': settings.try_job_settings,
244 'swarming_settings': settings.swarming_settings, 252 'swarming_settings': settings.swarming_settings,
245 'download_build_data_settings': settings.download_build_data_settings, 253 'download_build_data_settings': settings.download_build_data_settings,
254 'action_settings': settings.action_settings,
246 'version': settings.version, 255 'version': settings.version,
247 'latest_version': latest_version, 256 'latest_version': latest_version,
248 'updated_by': settings.updated_by, 257 'updated_by': settings.updated_by,
249 'updated_ts': _FormatTimestamp(settings.updated_ts) 258 'updated_ts': _FormatTimestamp(settings.updated_ts)
250 } 259 }
251 260
252 return {'template': 'config.html', 'data': data} 261 return {'template': 'config.html', 'data': data}
253 262
254 def HandlePost(self): 263 def HandlePost(self):
255 data = self.request.params.get('data') 264 data = self.request.params.get('data')
256 new_config_dict = json.loads(data) 265 new_config_dict = json.loads(data)
257 if not _ConfigurationDictIsValid(new_config_dict): # pragma: no cover 266 if not _ConfigurationDictIsValid(new_config_dict): # pragma: no cover
258 return self.CreateError( 267 return self.CreateError(
259 'New configuration settings is not properly formatted.', 400) 268 'New configuration settings is not properly formatted.', 400)
260 269
261 wf_config.FinditConfig.Get().Update(users.get_current_user(), 270 wf_config.FinditConfig.Get().Update(users.get_current_user(),
262 users.IsCurrentUserAdmin(), 271 users.IsCurrentUserAdmin(),
263 **new_config_dict) 272 **new_config_dict)
264 273
265 return self.HandleGet() 274 return self.HandleGet()
OLDNEW
« no previous file with comments | « no previous file | appengine/findit/handlers/test/config_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698