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

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

Issue 2605943002: Removing the mutation in the factories for getting dep repositories (Closed)
Patch Set: Added the Factory method to CachedGitilesRepository Created 3 years, 11 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
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 there's nothing we can do), then we will skip creating the pipeline 122 there's nothing we can do), then we will skip creating the pipeline
123 at all. 123 at all.
124 124
125 Args: 125 Args:
126 crash_data (JSON): ?? 126 crash_data (JSON): ??
127 127
128 Returns: 128 Returns:
129 True if we started a new pipeline; False otherwise. 129 True if we started a new pipeline; False otherwise.
130 """ 130 """
131 client_id = crash_data['client_id'] 131 client_id = crash_data['client_id']
132 repository = CachedGitilesRepository(HttpClientAppengine())
133 # N.B., must call FinditForClientID indirectly, for mock testing. 132 # N.B., must call FinditForClientID indirectly, for mock testing.
134 findit_client = crash_pipeline.FinditForClientID(client_id, repository) 133 findit_client = crash_pipeline.FinditForClientID(client_id,
134 CachedGitilesRepository.Factory(HttpClientAppengine()))
135 135
136 # Check policy and modify the crash_data as needed. 136 # Check policy and modify the crash_data as needed.
137 crash_data = findit_client.CheckPolicy(crash_data) 137 crash_data = findit_client.CheckPolicy(crash_data)
138 if crash_data is None: 138 if crash_data is None:
139 return False 139 return False
140 140
141 # Detect the regression range, and decide if we actually need to 141 # Detect the regression range, and decide if we actually need to
142 # run a new anlaysis or not. 142 # run a new anlaysis or not.
143 if not findit_client._NeedsNewAnalysis(crash_data): 143 if not findit_client._NeedsNewAnalysis(crash_data):
144 return False 144 return False
145 145
146 crash_identifiers = crash_data['crash_identifiers'] 146 crash_identifiers = crash_data['crash_identifiers']
147 # N.B., we cannot pass ``self`` directly to the _pipeline_cls, because 147 # 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, 148 # 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 149 # since JSON-serializability is defined by JSON-encoders rather than
150 # as methods on the objects being encoded). 150 # as methods on the objects being encoded).
151 pipeline = crash_pipeline.CrashWrapperPipeline(client_id, crash_identifiers) 151 pipeline = crash_pipeline.CrashWrapperPipeline(client_id, crash_identifiers)
152 # Attribute defined outside __init__ - pylint: disable=W0201 152 # Attribute defined outside __init__ - pylint: disable=W0201
153 pipeline.target = appengine_util.GetTargetNameForModule( 153 pipeline.target = appengine_util.GetTargetNameForModule(
154 constants.CRASH_BACKEND[client_id]) 154 constants.CRASH_BACKEND[client_id])
155 queue_name = constants.CRASH_ANALYSIS_QUEUE[client_id] 155 queue_name = constants.CRASH_ANALYSIS_QUEUE[client_id]
156 pipeline.start(queue_name=queue_name) 156 pipeline.start(queue_name=queue_name)
157 logging.info('New %s analysis is scheduled for %s', client_id, 157 logging.info('New %s analysis is scheduled for %s', client_id,
158 repr(crash_identifiers)) 158 repr(crash_identifiers))
159 return True 159 return True
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698