Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(860)

Side by Side Diff: appengine/findit/handlers/crash/crash_handler.py

Issue 2414523002: [Findit] Reorganizing findit_for_*.py (Closed)
Patch Set: Fixing call to ScheduleNewAnalysis in handlers/crash/crash_handler.py Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 json 6 import json
7 import logging 7 import logging
8 8
9 from common import constants 9 from common import constants
10 from common.base_handler import BaseHandler 10 from common.base_handler import BaseHandler
11 from common.base_handler import Permission 11 from common.base_handler import Permission
12 from crash import crash_pipeline 12 from crash import findit_for_chromecrash
13 from crash import findit_for_clusterfuzz
14 from crash.crash_report import CrashReport
15 from crash.type_enums import CrashClient
16
17
18 # TODO(wrengr): we'd like to move this to findit.py (or somewhere similar)
19 # so it's encapsulated along with the Findit classes; but to do that we'd
20 # need to merge findit.py and findit_for_chromecrash.py to avoid cyclic
21 # dependencies. Is there a clean way to do what we want?
22 def FinditForClientID(client_id):
23 if client_id == CrashClient.FRACAS:
24 return findit_for_chromecrash.FinditForFracas()
25 elif client_id == CrashClient.CRACAS:
26 return findit_for_chromecrash.FinditForCracas()
27 elif client_id == CrashClient.CLUSTERFUZZ:
28 return findit_for_clusterfuzz.FinditForClusterfuzz()
29 else:
30 logging.info('Client %s is not supported by findit right now', client_id)
31 raise ValueError()
13 32
14 33
15 class CrashHandler(BaseHandler): 34 class CrashHandler(BaseHandler):
16 PERMISSION_LEVEL = Permission.ANYONE 35 PERMISSION_LEVEL = Permission.ANYONE
17 36
18 def HandlePost(self): 37 def HandlePost(self):
19 """Handles push delivery from Pub/Sub for crash data. 38 """Handles push delivery from Pub/Sub for crash data.
20 39
21 The crash data should be in the following json format: 40 The crash data should be in the following json format:
22 { 41 {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 received_message = json.loads(self.request.body) 114 received_message = json.loads(self.request.body)
96 pubsub_message = received_message['message'] 115 pubsub_message = received_message['message']
97 crash_data = json.loads(base64.b64decode(pubsub_message['data'])) 116 crash_data = json.loads(base64.b64decode(pubsub_message['data']))
98 117
99 logging.info('Processing message %s from subscription %s.', 118 logging.info('Processing message %s from subscription %s.',
100 pubsub_message['message_id'], 119 pubsub_message['message_id'],
101 received_message['subscription']) 120 received_message['subscription'])
102 121
103 logging.info('Crash data is %s', json.dumps(crash_data)) 122 logging.info('Crash data is %s', json.dumps(crash_data))
104 123
105 crash_pipeline.ScheduleNewAnalysisForCrash( 124 client_id = crash_data['client_id']
106 crash_data['crash_identifiers'], 125 FinditForClientID(client_id).ScheduleNewAnalysis(crash_data,
107 crash_data['chrome_version'], 126 queue_name=constants.CRASH_ANALYSIS_QUEUE[client_id])
108 crash_data['signature'],
109 crash_data['client_id'],
110 crash_data['platform'],
111 crash_data['stack_trace'],
112 crash_data['customized_data'],
113 queue_name=constants.CRASH_ANALYSIS_QUEUE[crash_data['client_id']])
114 except (KeyError, ValueError): # pragma: no cover. 127 except (KeyError, ValueError): # pragma: no cover.
115 # TODO: save exception in datastore and create a page to show them. 128 # TODO: save exception in datastore and create a page to show them.
116 logging.exception('Failed to process crash message') 129 logging.exception('Failed to process crash message')
117 logging.info(self.request.body) 130 logging.info(self.request.body)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698