| OLD | NEW |
| 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, Permission | 9 from common.base_handler import BaseHandler, Permission |
| 10 from model import wf_config | 10 from model import wf_config |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 settings.get('cr_notification_latency_limit_minutes'), int)) | 184 settings.get('cr_notification_latency_limit_minutes'), int)) |
| 185 | 185 |
| 186 | 186 |
| 187 def _ValidateCheckFlakeSettings(settings): | 187 def _ValidateCheckFlakeSettings(settings): |
| 188 return (isinstance(settings, dict) and | 188 return (isinstance(settings, dict) and |
| 189 isinstance(settings.get('lower_flake_threshold'), float) and | 189 isinstance(settings.get('lower_flake_threshold'), float) and |
| 190 isinstance(settings.get('upper_flake_threshold'), float) and | 190 isinstance(settings.get('upper_flake_threshold'), float) and |
| 191 isinstance(settings.get('max_flake_in_a_row'), int) and | 191 isinstance(settings.get('max_flake_in_a_row'), int) and |
| 192 isinstance(settings.get('max_stable_in_a_row'), int) and | 192 isinstance(settings.get('max_stable_in_a_row'), int) and |
| 193 isinstance(settings.get('iterations_to_rerun'), int) and | 193 isinstance(settings.get('iterations_to_rerun'), int) and |
| 194 isinstance(settings.get('max_build_numbers_to_look_back'), int)) | 194 isinstance(settings.get('max_build_numbers_to_look_back'), int) and |
| 195 isinstance(settings.get('update_monorail_bug'), bool)) |
| 195 | 196 |
| 196 | 197 |
| 197 # Maps config properties to their validation functions. | 198 # Maps config properties to their validation functions. |
| 198 _CONFIG_VALIDATION_FUNCTIONS = { | 199 _CONFIG_VALIDATION_FUNCTIONS = { |
| 199 'steps_for_masters_rules': _ValidateMastersAndStepsRulesMapping, | 200 'steps_for_masters_rules': _ValidateMastersAndStepsRulesMapping, |
| 200 'builders_to_trybots': _ValidateTrybotMapping, | 201 'builders_to_trybots': _ValidateTrybotMapping, |
| 201 'try_job_settings': _ValidateTryJobSettings, | 202 'try_job_settings': _ValidateTryJobSettings, |
| 202 'swarming_settings': _ValidateSwarmingSettings, | 203 'swarming_settings': _ValidateSwarmingSettings, |
| 203 'download_build_data_settings': _ValidateDownloadBuildDataSettings, | 204 'download_build_data_settings': _ValidateDownloadBuildDataSettings, |
| 204 'action_settings': _ValidateActionSettings, | 205 'action_settings': _ValidateActionSettings, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 new_config_dict = json.loads(data) | 281 new_config_dict = json.loads(data) |
| 281 if not _ConfigurationDictIsValid(new_config_dict): # pragma: no cover | 282 if not _ConfigurationDictIsValid(new_config_dict): # pragma: no cover |
| 282 return self.CreateError( | 283 return self.CreateError( |
| 283 'New configuration settings is not properly formatted.', 400) | 284 'New configuration settings is not properly formatted.', 400) |
| 284 | 285 |
| 285 wf_config.FinditConfig.Get().Update(users.get_current_user(), | 286 wf_config.FinditConfig.Get().Update(users.get_current_user(), |
| 286 users.IsCurrentUserAdmin(), | 287 users.IsCurrentUserAdmin(), |
| 287 **new_config_dict) | 288 **new_config_dict) |
| 288 | 289 |
| 289 return self.HandleGet() | 290 return self.HandleGet() |
| OLD | NEW |