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

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

Issue 2673993003: [Predator] Pass config as argument to findit. (Closed)
Patch Set: Fix pylint. Created 3 years, 10 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 import appengine_util 10 from common import appengine_util
11 from common.base_handler import BaseHandler 11 from common.base_handler import BaseHandler
12 from common.base_handler import Permission 12 from common.base_handler import Permission
13 from crash import crash_pipeline 13 from crash import crash_pipeline
14 from crash.crash_report import CrashReport 14 from crash.crash_report import CrashReport
15 from gae_libs.gitiles.cached_gitiles_repository import CachedGitilesRepository 15 from gae_libs.gitiles.cached_gitiles_repository import CachedGitilesRepository
16 from gae_libs.http.http_client_appengine import HttpClientAppengine 16 from gae_libs.http.http_client_appengine import HttpClientAppengine
17 from model.crash.crash_config import CrashConfig
17 18
18 19
19 class CrashHandler(BaseHandler): 20 class CrashHandler(BaseHandler):
20 PERMISSION_LEVEL = Permission.ANYONE 21 PERMISSION_LEVEL = Permission.ANYONE
21 22
22 def HandlePost(self): 23 def HandlePost(self):
23 """Handles push delivery from Pub/Sub for crash data. 24 """Handles push delivery from Pub/Sub for crash data.
24 25
25 The crash data should be in the following json format: 26 The crash data should be in the following json format:
26 { 27 {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 at all. 124 at all.
124 125
125 Args: 126 Args:
126 crash_data (JSON): ?? 127 crash_data (JSON): ??
127 128
128 Returns: 129 Returns:
129 True if we started a new pipeline; False otherwise. 130 True if we started a new pipeline; False otherwise.
130 """ 131 """
131 client_id = crash_data['client_id'] 132 client_id = crash_data['client_id']
132 # N.B., must call FinditForClientID indirectly, for mock testing. 133 # N.B., must call FinditForClientID indirectly, for mock testing.
133 findit_client = crash_pipeline.FinditForClientID(client_id, 134 findit_client = crash_pipeline.FinditForClientID(
134 CachedGitilesRepository.Factory(HttpClientAppengine())) 135 client_id, CachedGitilesRepository.Factory(HttpClientAppengine()),
136 CrashConfig.Get())
135 137
136 # Check policy and modify the crash_data as needed. 138 # Check policy and modify the crash_data as needed.
137 crash_data = findit_client.CheckPolicy(crash_data) 139 crash_data = findit_client.CheckPolicy(crash_data)
138 if crash_data is None: 140 if crash_data is None:
139 return False 141 return False
140 142
141 # Detect the regression range, and decide if we actually need to 143 # Detect the regression range, and decide if we actually need to
142 # run a new anlaysis or not. 144 # run a new anlaysis or not.
143 if not findit_client._NeedsNewAnalysis(crash_data): 145 if not findit_client._NeedsNewAnalysis(crash_data):
144 return False 146 return False
145 147
146 crash_identifiers = crash_data['crash_identifiers'] 148 crash_identifiers = crash_data['crash_identifiers']
147 # N.B., we cannot pass ``self`` directly to the _pipeline_cls, because 149 # N.B., we cannot pass ``self`` directly to the _pipeline_cls, because
148 # it is not JSON-serializable (and there's no way to make it such, 150 # it is not JSON-serializable (and there's no way to make it such,
149 # since JSON-serializability is defined by JSON-encoders rather than 151 # since JSON-serializability is defined by JSON-encoders rather than
150 # as methods on the objects being encoded). 152 # as methods on the objects being encoded).
151 pipeline = crash_pipeline.CrashWrapperPipeline(client_id, crash_identifiers) 153 pipeline = crash_pipeline.CrashWrapperPipeline(client_id, crash_identifiers)
152 # Attribute defined outside __init__ - pylint: disable=W0201 154 # Attribute defined outside __init__ - pylint: disable=W0201
153 pipeline.target = appengine_util.GetTargetNameForModule( 155 pipeline.target = appengine_util.GetTargetNameForModule(
154 constants.CRASH_BACKEND[client_id]) 156 constants.CRASH_BACKEND[client_id])
155 queue_name = constants.CRASH_ANALYSIS_QUEUE[client_id] 157 queue_name = constants.CRASH_ANALYSIS_QUEUE[client_id]
156 pipeline.start(queue_name=queue_name) 158 pipeline.start(queue_name=queue_name)
157 logging.info('New %s analysis is scheduled for %s', client_id, 159 logging.info('New %s analysis is scheduled for %s', client_id,
158 repr(crash_identifiers)) 160 repr(crash_identifiers))
159 return True 161 return True
OLDNEW
« no previous file with comments | « appengine/findit/crash/test/findit_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