| Index: appengine/findit/crash/findit.py
|
| diff --git a/appengine/findit/crash/findit.py b/appengine/findit/crash/findit.py
|
| index 2fe8f8b02e499f26d0b714c60a12e30b77612986..932a324aa7519e3211d62498668281bd8b308609 100644
|
| --- a/appengine/findit/crash/findit.py
|
| +++ b/appengine/findit/crash/findit.py
|
| @@ -3,6 +3,7 @@
|
| # found in the LICENSE file.
|
|
|
| import copy
|
| +import json
|
| import logging
|
|
|
| from google.appengine.ext import ndb
|
| @@ -217,6 +218,41 @@ class Findit(object):
|
|
|
| return stacktrace
|
|
|
| + def ProcessResultForPublishing(self, result, key):
|
| + """Client specific processing of result data for publishing."""
|
| + raise NotImplementedError()
|
| +
|
| + def GetPublishableResult(self, crash_identifiers, analysis):
|
| + """Convert a culprit result into a publishable result for client.
|
| +
|
| + Note, this function must be called by a concrete subclass of CrashAnalysis
|
| + which implements the ProcessResultForPublishing method.
|
| +
|
| + Args:
|
| + crash_identifiers (dict): Dict containing identifiers that can uniquely
|
| + identify CrashAnalysis entity.
|
| + analysis (CrashAnalysis model): Model containing culprit result and other
|
| + analysis information.
|
| +
|
| + Returns:
|
| + A dict of the given ``crash_identifiers``, this model's
|
| + ``client_id``, and a publishable version of this model's ``result``.
|
| + """
|
| + result = copy.deepcopy(analysis.result)
|
| + if result.get('found') and 'suspected_cls' in result:
|
| + for cl in result['suspected_cls']:
|
| + cl['confidence'] = round(cl['confidence'], 2)
|
| + cl.pop('reason', None)
|
| +
|
| + result = self.ProcessResultForPublishing(result, analysis.key.urlsafe())
|
| + logging.info('Publish result:\n%s',
|
| + json.dumps(result, indent=4, sort_keys=True))
|
| + return {
|
| + 'crash_identifiers': crash_identifiers,
|
| + 'client_id': self.client_id,
|
| + 'result': result,
|
| + }
|
| +
|
| # TODO(wrengr): This is only called by ``CrashAnalysisPipeline.run``;
|
| # we should be able to adjust things so that we only need to take in
|
| # ``crash_identifiers``, or a CrashReport, rather than taking in the
|
|
|