| 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 copy | 5 import copy |
| 6 import hashlib | 6 import hashlib |
| 7 import json | 7 import json |
| 8 import logging | 8 import logging |
| 9 | 9 |
| 10 from google.appengine.ext import ndb | 10 from google.appengine.ext import ndb |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 @classmethod | 151 @classmethod |
| 152 def Get(cls, crash_identifiers): | 152 def Get(cls, crash_identifiers): |
| 153 return cls._CreateKey(crash_identifiers).get() | 153 return cls._CreateKey(crash_identifiers).get() |
| 154 | 154 |
| 155 @classmethod | 155 @classmethod |
| 156 def Create(cls, crash_identifiers): | 156 def Create(cls, crash_identifiers): |
| 157 return cls(key=cls._CreateKey(crash_identifiers)) | 157 return cls(key=cls._CreateKey(crash_identifiers)) |
| 158 | 158 |
| 159 def ToPublishableResult(self, crash_identifiers): | 159 def ToPublishableResult(self, crash_identifiers): |
| 160 """Convert this datastore analysis into a publishable result. | 160 """Convert this datastore analysis into a publishable result. |
| 161 | 161 |
| 162 Args: | 162 Args: |
| 163 crash_identifiers (dict): ?? | 163 crash_identifiers (dict): ?? |
| 164 | 164 |
| 165 Returns: | 165 Returns: |
| 166 A dict of the given ``crash_identifiers``, this model's | 166 A dict of the given ``crash_identifiers``, this model's |
| 167 ``client_id``, and a publishable version of this model's ``result``. | 167 ``client_id``, and a publishable version of this model's ``result``. |
| 168 """ | 168 """ |
| 169 result = copy.deepcopy(self.result) | 169 result = copy.deepcopy(self.result) |
| 170 client_id = self.client_id | 170 client_id = self.client_id |
| 171 | 171 |
| 172 # TODO(katesonia): move this to ChromeCrashAnalysis | 172 # TODO(katesonia): move this to ChromeCrashAnalysis |
| 173 if (client_id == CrashClient.FRACAS or | 173 if (client_id == CrashClient.FRACAS or |
| 174 client_id == CrashClient.CRACAS): | 174 client_id == CrashClient.CRACAS): |
| 175 result['feedback_url'] = _FINDIT_FRACAS_FEEDBACK_URL_TEMPLATE % ( | 175 result['feedback_url'] = _FINDIT_FRACAS_FEEDBACK_URL_TEMPLATE % ( |
| 176 appengine_util.GetDefaultVersionHostname(), self.key.urlsafe()) | 176 appengine_util.GetDefaultVersionHostname(), self.key.urlsafe()) |
| 177 if result['found']: | 177 if result['found'] and 'suspected_cls' in result: |
| 178 for cl in result['suspected_cls']: | 178 for cl in result['suspected_cls']: |
| 179 cl['confidence'] = round(cl['confidence'], 2) | 179 cl['confidence'] = round(cl['confidence'], 2) |
| 180 cl.pop('reason', None) | 180 cl.pop('reason', None) |
| 181 elif client_id == CrashClient.CLUSTERFUZZ: # pragma: no cover. | 181 elif client_id == CrashClient.CLUSTERFUZZ: # pragma: no cover. |
| 182 # TODO(katesonia): Post process clusterfuzz model result if needed. | 182 # TODO(katesonia): Post process clusterfuzz model result if needed. |
| 183 pass | 183 pass |
| 184 | 184 |
| 185 logging.info('Publish result:\n%s', |
| 186 json.dumps(result, indent=4, sort_keys=True)) |
| 185 return { | 187 return { |
| 186 'crash_identifiers': crash_identifiers, | 188 'crash_identifiers': crash_identifiers, |
| 187 'client_id': client_id, | 189 'client_id': client_id, |
| 188 'result': result, | 190 'result': result, |
| 189 } | 191 } |
| OLD | NEW |