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

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

Issue 2432203003: [Predator] Run predator. (Closed)
Patch Set: . 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 common.http_client_appengine import HttpClientAppengine
12 from crash.crash_pipeline import FinditForClientID 13 from crash.crash_pipeline import FinditForClientID
13 from crash.crash_report import CrashReport 14 from crash.crash_report import CrashReport
15 from lib.gitiles.gitiles_repository import GitilesRepository
14 16
15 17
16 class CrashHandler(BaseHandler): 18 class CrashHandler(BaseHandler):
17 PERMISSION_LEVEL = Permission.ANYONE 19 PERMISSION_LEVEL = Permission.ANYONE
18 20
19 def HandlePost(self): 21 def HandlePost(self):
20 """Handles push delivery from Pub/Sub for crash data. 22 """Handles push delivery from Pub/Sub for crash data.
21 23
22 The crash data should be in the following json format: 24 The crash data should be in the following json format:
23 { 25 {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 pubsub_message = received_message['message'] 99 pubsub_message = received_message['message']
98 crash_data = json.loads(base64.b64decode(pubsub_message['data'])) 100 crash_data = json.loads(base64.b64decode(pubsub_message['data']))
99 101
100 logging.info('Processing message %s from subscription %s.', 102 logging.info('Processing message %s from subscription %s.',
101 pubsub_message['message_id'], 103 pubsub_message['message_id'],
102 received_message['subscription']) 104 received_message['subscription'])
103 105
104 logging.info('Crash data is %s', json.dumps(crash_data)) 106 logging.info('Crash data is %s', json.dumps(crash_data))
105 107
106 client_id = crash_data['client_id'] 108 client_id = crash_data['client_id']
107 FinditForClientID(client_id).ScheduleNewAnalysis(crash_data, 109 repository = GitilesRepository(http_client=HttpClientAppengine())
110 FinditForClientID(client_id, repository).ScheduleNewAnalysis(
111 crash_data,
108 queue_name=constants.CRASH_ANALYSIS_QUEUE[client_id]) 112 queue_name=constants.CRASH_ANALYSIS_QUEUE[client_id])
109 except (KeyError, ValueError): # pragma: no cover. 113 except (KeyError, ValueError): # pragma: no cover.
110 # TODO: save exception in datastore and create a page to show them. 114 # TODO: save exception in datastore and create a page to show them.
111 logging.exception('Failed to process crash message') 115 logging.exception('Failed to process crash message')
112 logging.info(self.request.body) 116 logging.info(self.request.body)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698