def get(self): """Response handler for the page used to group an alert with a bug. Request parameters: bug_id: Bug ID number, as a string (when submitting the form). keys: Comma-separated alert keys in urlsafe format. confirm: If non-empty, associate alerts with a bug ID even if it appears that the alerts already associated with that bug have a non-overlapping revision range. Outputs: HTML with result. """ if not utils.IsValidSheriffUser(): user = users.get_current_user() self.ReportError('User "%s" not authorized.' % user, status=403) return urlsafe_keys = self.request.get('keys') if not urlsafe_keys: self.RenderHtml('bug_result.html', {'error': 'No alerts specified to add bugs to.'}) return is_confirmed = bool(self.request.get('confirm')) bug_id = self.request.get('bug_id') if bug_id: self._AssociateAlertsWithBug(bug_id, urlsafe_keys, is_confirmed) else: self._ShowCommentDialog(urlsafe_keys)
def post(self): """Performs one of several bisect-related actions depending on parameters. The only required parameter is "step", which indicates what to do. This end-point should always output valid JSON with different contents depending on the value of "step". """ user = users.get_current_user() if not utils.IsValidSheriffUser(): message = 'User "%s" not authorized.' % user self.response.out.write(json.dumps({'error': message})) return step = self.request.get('step') if step == 'prefill-info': result = _PrefillInfo(self.request.get('test_path')) elif step == 'perform-bisect': result = self._PerformBisectStep(user) elif step == 'perform-perf-try': result = self._PerformPerfTryStep(user) else: result = {'error': 'Invalid parameters.'} self.response.write(json.dumps(result))
def post(self): """Handles post requests from bad_bisect.html.""" if not utils.IsValidSheriffUser(): self._RenderError('No permission.') return if not self.request.get('try_job_id'): self._RenderError('Missing try_job_id.') return try_job_id = int(self.request.get('try_job_id')) job = try_job.TryJob.get_by_id(try_job_id) if not job: self._RenderError('TryJob doesn\'t exist.') return user = users.get_current_user() email = user.email() if not job.bad_result_emails: job.bad_result_emails = set() if email not in job.bad_result_emails: job.bad_result_emails.add(email) job.put() _LogFeedback(try_job_id, email) self.RenderHtml( 'result.html', {'headline': 'Confirmed bad bisect. Thank you for reporting.'})
def get(self): """Either shows the form to file a bug, or if filled in, files the bug. The form to file a bug is popped up from the triage-dialog polymer element. The default summary, description and label strings are constructed there. Request parameters: summary: Bug summary string. description: Bug full description string. owner: Bug owner email address. keys: Comma-separated Alert keys in urlsafe format. Outputs: HTML, using the template 'bug_result.html'. """ if not utils.IsValidSheriffUser(): user = users.get_current_user() self.ReportError('User "%s" not authorized.' % user, status=403) return summary = self.request.get('summary') description = self.request.get('description') labels = self.request.get_all('label') keys = self.request.get('keys') if not keys: self.RenderHtml('bug_result.html', {'error': 'No alerts specified to add bugs to.'}) return if self.request.get('finish'): self._CreateBug(summary, description, labels, keys) else: self._ShowBugDialog(summary, description, keys)
def _RenderForm(self): if not utils.IsValidSheriffUser(): self._RenderError('No permission.') return if not self.request.get('try_job_id'): self._RenderError('Missing try_job_id.') return self.RenderHtml('bad_bisect.html', {'try_job_id': self.request.get('try_job_id')})
def get(self): """Renders bad_bisect.html.""" if not utils.IsValidSheriffUser(): self._RenderError('No permission.') return if self.request.get('list'): self.response.out.write(_PrintRecentFeedback()) return if not self.request.get('try_job_id'): self._RenderError('Missing try_job_id.') return self.RenderHtml('bad_bisect.html', {'try_job_id': self.request.get('try_job_id')})
def post(self): """Allows adding or resetting bug IDs and invalid statuses to Alerts. Additionally, this endpoint is also responsible for changing the start and end revisions of Anomaly entities. Request parameters: keys: A comma-separated list of urlsafe keys of Anomaly entities. bug_id: The new bug ID. This should be either the string REMOVE (indicating resetting the bug ID to None), or an integer. A negative integer indicates an invalid or ignored alert. If this is given, then the start and end revision ranges are ignored. new_start_revision: New start revision value for the alert. new_end_revision: New end revision value for the alert. Outputs: JSON which indicates the result. If an error has occurred, the field "error" should be in the result. If successful, the response is still expected to be JSON. """ if not utils.IsValidSheriffUser(): user = users.get_current_user() self.ReportError('User "%s" not authorized.' % user, status=403) return # Get the list of alerts to modify. urlsafe_keys = self.request.get('keys') if not urlsafe_keys: self.response.out.write( json.dumps({'error': 'No alerts specified to add bugs to.'})) return keys = [ndb.Key(urlsafe=k) for k in urlsafe_keys.split(',')] alert_entities = ndb.get_multi(keys) # Get the parameters which specify the changes to make. bug_id = self.request.get('bug_id') new_start_revision = self.request.get('new_start_revision') new_end_revision = self.request.get('new_end_revision') if bug_id: self.ChangeBugId(alert_entities, bug_id) elif new_start_revision and new_end_revision: self.NudgeAnomalies(alert_entities, new_start_revision, new_end_revision) else: self.response.out.write( json.dumps({'error': 'No bug ID or new revision specified.'}))
def get(self): """Either shows the form to file a bug, or if filled in, files the bug. The form to file a bug is popped up from the triage-dialog polymer element. The default summary, description and label strings are constructed there. Request parameters: summary: Bug summary string. description: Bug full description string. owner: Bug owner email address. keys: Comma-separated Alert keys in urlsafe format. Outputs: HTML, using the template 'bug_result.html'. """ if not utils.IsValidSheriffUser(): # TODO(qyearsley): Simplify this message (after a couple months). self.RenderHtml( 'bug_result.html', { 'error': ('You must be logged in with a chromium.org account ' 'in order to file bugs here! This is the case ever ' 'since we switched to the Monorail issue tracker. ' 'Note, viewing internal data should work for Googlers ' 'that are logged in with the Chromium accounts. See ' 'https://github.com/catapult-project/catapult/issues/2042' ) }) return summary = self.request.get('summary') description = self.request.get('description') labels = self.request.get_all('label') components = self.request.get_all('component') keys = self.request.get('keys') if not keys: self.RenderHtml('bug_result.html', {'error': 'No alerts specified to add bugs to.'}) return if self.request.get('finish'): self._CreateBug(summary, description, labels, components, keys) else: self._ShowBugDialog(summary, description, keys)