Chromium Code Reviews| 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 base64 | 5 import base64 |
| 6 import copy | |
| 6 import datetime | 7 import datetime |
| 7 import json | 8 import json |
| 8 import logging | 9 import logging |
| 9 | 10 |
| 10 from google.appengine.ext import ndb | 11 from google.appengine.ext import ndb |
| 11 | 12 |
| 12 from common import appengine_util | 13 from common import appengine_util |
| 13 from common import constants | 14 from common import constants |
| 14 from common import pubsub_util | 15 from common import pubsub_util |
| 15 from common.pipeline_wrapper import BasePipeline | 16 from common.pipeline_wrapper import BasePipeline |
| 16 from common.pipeline_wrapper import pipeline | 17 from common.pipeline_wrapper import pipeline |
| 17 from crash import fracas | 18 from crash import fracas |
| 18 from model import analysis_status | 19 from model import analysis_status |
| 19 from model.crash.crash_config import CrashConfig | 20 from model.crash.crash_config import CrashConfig |
| 20 from model.crash.fracas_crash_analysis import FracasCrashAnalysis | 21 from model.crash.fracas_crash_analysis import FracasCrashAnalysis |
| 21 | 22 |
| 22 | 23 |
| 23 # TODO(katesonia): Move these to config page. | 24 # TODO(katesonia): Move these to config page. |
| 24 _SIGNATURE_BLACKLIST_MARKERS = ['[Android Java Exception]'] | 25 _SIGNATURE_BLACKLIST_MARKERS = ['[Android Java Exception]'] |
| 25 _PLATFORM_RENAME = {'linux': 'unix'} | 26 _PLATFORM_RENAME = {'linux': 'unix'} |
| 27 _FINDIT_FEEDBACK_URL_TEMPLATE = ('https://findit-for-me.googleplex.com/crash/' | |
|
stgao
2016/08/18 18:30:46
The hostname should go to the config instead.
| |
| 28 'fracas-result-feedback?key=%s') | |
| 26 | 29 |
| 27 | 30 |
| 28 class FracasBasePipeline(BasePipeline): | 31 class FracasBasePipeline(BasePipeline): |
| 29 def __init__(self, crash_identifiers): | 32 def __init__(self, crash_identifiers): |
| 30 super(FracasBasePipeline, self).__init__(crash_identifiers) | 33 super(FracasBasePipeline, self).__init__(crash_identifiers) |
| 31 self.crash_identifiers = crash_identifiers | 34 self.crash_identifiers = crash_identifiers |
| 32 | 35 |
| 33 def run(self, *args, **kwargs): | 36 def run(self, *args, **kwargs): |
| 34 raise NotImplementedError() | 37 raise NotImplementedError() |
| 35 | 38 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 analysis.status = analysis_status.COMPLETED | 76 analysis.status = analysis_status.COMPLETED |
| 74 analysis.put() | 77 analysis.put() |
| 75 | 78 |
| 76 | 79 |
| 77 class PublishResultPipeline(FracasBasePipeline): | 80 class PublishResultPipeline(FracasBasePipeline): |
| 78 def finalized(self): | 81 def finalized(self): |
| 79 if self.was_aborted: # pragma: no cover. | 82 if self.was_aborted: # pragma: no cover. |
| 80 logging.error('Failed to publish analysis result for %s', | 83 logging.error('Failed to publish analysis result for %s', |
| 81 repr(self.crash_identifiers)) | 84 repr(self.crash_identifiers)) |
| 82 | 85 |
| 86 def PostProcessResults(self, analysis, crash_identifiers): | |
| 87 analysis_result = copy.deepcopy(analysis.result) | |
| 88 analysis_result['feedback_url'] = (_FINDIT_FEEDBACK_URL_TEMPLATE % | |
| 89 analysis.key.urlsafe()) | |
| 90 if analysis_result['found']: | |
| 91 for cl in analysis_result['suspected_cls']: | |
| 92 cl['confidence'] = round(cl['confidence'], 2) | |
| 93 cl.pop('reason', None) | |
| 94 | |
| 95 return { | |
| 96 'crash_identifiers': crash_identifiers, | |
| 97 'client_id': analysis.client_id, | |
| 98 'result': analysis_result, | |
| 99 } | |
| 100 | |
| 83 # Arguments number differs from overridden method - pylint: disable=W0221 | 101 # Arguments number differs from overridden method - pylint: disable=W0221 |
| 84 def run(self, crash_identifiers): | 102 def run(self, crash_identifiers): |
| 85 analysis = FracasCrashAnalysis.Get(crash_identifiers) | 103 analysis = FracasCrashAnalysis.Get(crash_identifiers) |
| 86 result = { | 104 result = self.PostProcessResults(analysis, crash_identifiers) |
| 87 'crash_identifiers': crash_identifiers, | |
| 88 'client_id': analysis.client_id, | |
| 89 'result': analysis.result, | |
| 90 } | |
| 91 messages_data = [json.dumps(result, sort_keys=True)] | 105 messages_data = [json.dumps(result, sort_keys=True)] |
| 92 | 106 |
| 93 crash_config = CrashConfig.Get() | 107 crash_config = CrashConfig.Get() |
| 94 topic = crash_config.fracas['analysis_result_pubsub_topic'] | 108 topic = crash_config.fracas['analysis_result_pubsub_topic'] |
| 95 pubsub_util.PublishMessagesToTopic(messages_data, topic) | 109 pubsub_util.PublishMessagesToTopic(messages_data, topic) |
| 96 logging.info('Published analysis result for %s', repr(crash_identifiers)) | 110 logging.info('Published analysis result for %s', repr(crash_identifiers)) |
| 97 | 111 |
| 98 | 112 |
| 99 class FracasCrashWrapperPipeline(BasePipeline): | 113 class FracasCrashWrapperPipeline(BasePipeline): |
| 100 # Arguments number differs from overridden method - pylint: disable=W0221 | 114 # Arguments number differs from overridden method - pylint: disable=W0221 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 platform, stack_trace, channel, historical_metadata): | 185 platform, stack_trace, channel, historical_metadata): |
| 172 analysis_pipeline = FracasCrashWrapperPipeline(crash_identifiers) | 186 analysis_pipeline = FracasCrashWrapperPipeline(crash_identifiers) |
| 173 # Attribute defined outside __init__ - pylint: disable=W0201 | 187 # Attribute defined outside __init__ - pylint: disable=W0201 |
| 174 analysis_pipeline.target = appengine_util.GetTargetNameForModule( | 188 analysis_pipeline.target = appengine_util.GetTargetNameForModule( |
| 175 constants.CRASH_BACKEND_FRACAS) | 189 constants.CRASH_BACKEND_FRACAS) |
| 176 analysis_pipeline.start(queue_name=queue_name) | 190 analysis_pipeline.start(queue_name=queue_name) |
| 177 logging.info('New analysis is scheduled for %s', repr(crash_identifiers)) | 191 logging.info('New analysis is scheduled for %s', repr(crash_identifiers)) |
| 178 return True | 192 return True |
| 179 | 193 |
| 180 return False | 194 return False |
| OLD | NEW |