| OLD | NEW |
| (Empty) | |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import base64 |
| 6 from collections import defaultdict |
| 7 import copy |
| 8 from datetime import datetime |
| 9 import json |
| 10 import os |
| 11 |
| 12 from google.appengine.ext import ndb |
| 13 from google.appengine.api import users |
| 14 |
| 15 from common import constants |
| 16 from common import time_util |
| 17 from common.base_handler import BaseHandler |
| 18 from common.base_handler import Permission |
| 19 from handlers import handlers_util |
| 20 from handlers import result_status |
| 21 from handlers.result_status import NO_TRY_JOB_REASON_MAP |
| 22 from model.crash.fracas_crash_analysis import FracasCrashAnalysis |
| 23 from model import triage_status |
| 24 |
| 25 |
| 26 def _GetTriageHistory(analysis): |
| 27 if (not users.is_current_user_admin() or |
| 28 not analysis.completed or |
| 29 not analysis.triage_history): |
| 30 return None |
| 31 |
| 32 triage_history = [] |
| 33 for triage_record in analysis.triage_history: |
| 34 triage_history.append({ |
| 35 'triage_time': time_util.FormatDatetime( |
| 36 datetime.utcfromtimestamp(triage_record['triage_timestamp'])), |
| 37 'result_property': triage_record['result_property'], |
| 38 'user_name': triage_record['user_name'], |
| 39 'triage_status': triage_record['triage_status'] |
| 40 }) |
| 41 |
| 42 return triage_history |
| 43 |
| 44 |
| 45 class FracasResultFeedback(BaseHandler): |
| 46 PERMISSION_LEVEL = Permission.ANYONE |
| 47 |
| 48 def _GetCrashDataFromAnalysis(self, analysis): |
| 49 print analysis.culprit_cls |
| 50 return { |
| 51 'signature': analysis.signature, |
| 52 'version': analysis.crashed_version, |
| 53 'channel': analysis.channel, |
| 54 'platform': analysis.platform, |
| 55 'regression_range': ( |
| 56 analysis.result['regression_range'] if 'regression_range' in |
| 57 analysis.result else None), |
| 58 'culprit_regression_range': analysis.culprit_regression_range, |
| 59 'historical_metadata': analysis.historical_metadata, |
| 60 'stack_trace': analysis.stack_trace, |
| 61 'suspected_cls': ( |
| 62 analysis.result['suspected_cls'] if 'suspected_cls' in |
| 63 analysis.result else None), |
| 64 'culprit_cls': analysis.culprit_cls, |
| 65 'suspected_project': ( |
| 66 analysis.result['suspected_project'] if 'suspected_project' in |
| 67 analysis.result else None), |
| 68 'culprit_project': analysis.culprit_project, |
| 69 'suspected_components': ( |
| 70 analysis.result['suspected_components'] if 'suspected_components' |
| 71 in analysis.result else None), |
| 72 'culprit_components': analysis.culprit_components, |
| 73 'request_time': time_util.FormatDatetime(analysis.requested_time), |
| 74 'triage_history': _GetTriageHistory(analysis), |
| 75 'analysis_completed': analysis.completed, |
| 76 'analysis_failed': analysis.failed, |
| 77 'analysis_correct': { |
| 78 'regression_range': analysis.regression_range_triage_status, |
| 79 'suspected_cls': analysis.suspected_cls_triage_status, |
| 80 'suspected_project': analysis.suspected_project_triage_status, |
| 81 'suspected_components': analysis.suspected_components_triage_status, |
| 82 }, |
| 83 'note': analysis.note, |
| 84 'key': self.request.get('key'), |
| 85 } |
| 86 |
| 87 def HandleGet(self): |
| 88 """Triggers analysis of a build failure on demand and return current result. |
| 89 |
| 90 If the final analysis result is available, set cache-control to 1 day to |
| 91 avoid overload by unnecessary and frequent query from clients; otherwise |
| 92 set cache-control to 5 seconds to allow repeated query. |
| 93 |
| 94 Serve HTML page or JSON result as requested. |
| 95 """ |
| 96 key = ndb.Key(urlsafe=self.request.get('key')) |
| 97 |
| 98 analysis = key.get() |
| 99 if not analysis: # pragma: no cover. |
| 100 return BaseHandler.CreateError( |
| 101 'cannot find analysis for crash %s' % analysis.signature) |
| 102 |
| 103 return { |
| 104 'template': 'crash/fracas_result_feedback.html', |
| 105 'data': self._GetCrashDataFromAnalysis(analysis), |
| 106 } |
| 107 |
| 108 def HandlePost(self): # pragma: no cover |
| 109 return self.HandleGet() |
| OLD | NEW |