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

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

Issue 2414523002: [Findit] Reorganizing findit_for_*.py (Closed)
Patch Set: Finally fixed the mock tests! Created 4 years, 1 month 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.crash_pipeline import FinditForClientID
13 from crash.crash_report import CrashReport
13 14
14 15
15 class CrashHandler(BaseHandler): 16 class CrashHandler(BaseHandler):
16 PERMISSION_LEVEL = Permission.ANYONE 17 PERMISSION_LEVEL = Permission.ANYONE
17 18
18 def HandlePost(self): 19 def HandlePost(self):
19 """Handles push delivery from Pub/Sub for crash data. 20 """Handles push delivery from Pub/Sub for crash data.
20 21
21 The crash data should be in the following json format: 22 The crash data should be in the following json format:
22 { 23 {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 received_message = json.loads(self.request.body) 96 received_message = json.loads(self.request.body)
96 pubsub_message = received_message['message'] 97 pubsub_message = received_message['message']
97 crash_data = json.loads(base64.b64decode(pubsub_message['data'])) 98 crash_data = json.loads(base64.b64decode(pubsub_message['data']))
98 99
99 logging.info('Processing message %s from subscription %s.', 100 logging.info('Processing message %s from subscription %s.',
100 pubsub_message['message_id'], 101 pubsub_message['message_id'],
101 received_message['subscription']) 102 received_message['subscription'])
102 103
103 logging.info('Crash data is %s', json.dumps(crash_data)) 104 logging.info('Crash data is %s', json.dumps(crash_data))
104 105
105 crash_pipeline.ScheduleNewAnalysisForCrash( 106 client_id = crash_data['client_id']
106 crash_data['crash_identifiers'], 107 FinditForClientID(client_id).ScheduleNewAnalysis(crash_data,
107 crash_data['chrome_version'], 108 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. 109 except (KeyError, ValueError): # pragma: no cover.
115 # TODO: save exception in datastore and create a page to show them. 110 # TODO: save exception in datastore and create a page to show them.
116 logging.exception('Failed to process crash message') 111 logging.exception('Failed to process crash message')
117 logging.info(self.request.body) 112 logging.info(self.request.body)
OLDNEW
« no previous file with comments | « appengine/findit/crash/test/stacktrace_test.py ('k') | appengine/findit/handlers/crash/test/crash_handler_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698