| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 json | 5 import json |
| 6 import webapp2 | 6 import webapp2 |
| 7 | 7 |
| 8 from dashboard.api import api_auth | 8 from dashboard.api import api_auth |
| 9 from dashboard.pinpoint.handlers import quest_generator | 9 from dashboard.pinpoint.handlers import quest_generator |
| 10 from dashboard.pinpoint.models import change | 10 from dashboard.pinpoint.models import change |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 self.response.out.write(json.dumps({'error': message})) | 27 self.response.out.write(json.dumps({'error': message})) |
| 28 | 28 |
| 29 @api_auth.Authorize | 29 @api_auth.Authorize |
| 30 def _CreateJob(self): | 30 def _CreateJob(self): |
| 31 """Start a new Pinpoint job.""" | 31 """Start a new Pinpoint job.""" |
| 32 repeat_count = self.request.get('repeat_count') | 32 repeat_count = self.request.get('repeat_count') |
| 33 auto_explore = self.request.get('auto_explore') == '1' | 33 auto_explore = self.request.get('auto_explore') == '1' |
| 34 bug_id = self.request.get('bug_id') | 34 bug_id = self.request.get('bug_id') |
| 35 | 35 |
| 36 change_1 = { | 36 change_1 = { |
| 37 'base_commit': { | 37 'commits': [{ |
| 38 'repository': self.request.get('start_repository'), | 38 'repository': self.request.get('start_repository'), |
| 39 'git_hash': self.request.get('start_git_hash') | 39 'git_hash': self.request.get('start_git_hash') |
| 40 } | 40 }] |
| 41 } | 41 } |
| 42 | 42 |
| 43 change_2 = { | 43 change_2 = { |
| 44 'base_commit': { | 44 'commits': [{ |
| 45 'repository': self.request.get('end_repository'), | 45 'repository': self.request.get('end_repository'), |
| 46 'git_hash': self.request.get('end_git_hash') | 46 'git_hash': self.request.get('end_git_hash') |
| 47 } | 47 }] |
| 48 } | 48 } |
| 49 | 49 |
| 50 # Validate arguments and convert them to canonical internal representation. | 50 # Validate arguments and convert them to canonical internal representation. |
| 51 arguments, quests = quest_generator.GenerateQuests(self.request) | 51 arguments, quests = quest_generator.GenerateQuests(self.request) |
| 52 repeat_count = _ValidateRepeatCount(repeat_count) | 52 repeat_count = _ValidateRepeatCount(repeat_count) |
| 53 bug_id = _ValidateBugId(bug_id) | 53 bug_id = _ValidateBugId(bug_id) |
| 54 changes = _ValidateChanges(change_1, change_2) | 54 changes = _ValidateChanges(change_1, change_2) |
| 55 | 55 |
| 56 # Create job. | 56 # Create job. |
| 57 job = job_module.Job.New( | 57 job = job_module.Job.New( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 return None | 95 return None |
| 96 | 96 |
| 97 try: | 97 try: |
| 98 return int(bug_id) | 98 return int(bug_id) |
| 99 except ValueError: | 99 except ValueError: |
| 100 raise ValueError(_ERROR_BUG_ID) | 100 raise ValueError(_ERROR_BUG_ID) |
| 101 | 101 |
| 102 | 102 |
| 103 def _ValidateChanges(change_1, change_2): | 103 def _ValidateChanges(change_1, change_2): |
| 104 return (change.Change.FromDict(change_1), change.Change.FromDict(change_2)) | 104 return (change.Change.FromDict(change_1), change.Change.FromDict(change_2)) |
| OLD | NEW |