Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 from datetime import date | 5 from datetime import date |
| 6 from datetime import datetime | 6 from datetime import datetime |
| 7 from datetime import timedelta | 7 from datetime import timedelta |
| 8 | 8 |
| 9 from crash.type_enums import CrashClient | 9 from crash.type_enums import CrashClient |
| 10 import iterator | 10 import iterator |
| 11 from model.crash.cracas_crash_analysis import CracasCrashAnalysis | 11 from model.crash.cracas_crash_analysis import CracasCrashAnalysis |
| 12 from model.crash.fracas_crash_analysis import FracasCrashAnalysis | 12 from model.crash.fracas_crash_analysis import FracasCrashAnalysis |
| 13 import remote_api | 13 import remote_api |
| 14 | 14 |
| 15 _DEFAULT_BATCH_SIZE = 1000 | 15 _DEFAULT_BATCH_SIZE = 1000 |
| 16 _TODAY = date.today().strftime('%Y-%m-%d') | 16 _TODAY = date.today().strftime('%Y-%m-%d') |
| 17 _A_YEAR_AGO = (date.today() - timedelta(days=365)).strftime('%Y-%m-%d') | 17 _A_YEAR_AGO = (date.today() - timedelta(days=365)).strftime('%Y-%m-%d') |
| 18 | 18 |
| 19 COMMON_CRASH_FIELDS = ['crashed_version', 'stack_trace', 'signature', | |
| 20 'platform', 'client_id', 'customized_data'] | |
| 21 | |
| 22 | 19 |
| 23 # TODO(katesonia): Switch to use fuction of objects encapsulating CrashClients, | 20 # TODO(katesonia): Switch to use fuction of objects encapsulating CrashClients, |
| 24 # after the refactoring is done. | 21 # after the refactoring is done. |
| 25 def GetAnalysisClassForClient(client_id): | 22 def GetAnalysisClassForClient(client_id): |
|
wrengr
2016/11/01 22:07:52
For future reference: You should be able to replac
Sharu Jiang
2016/11/11 23:10:26
This one is to return Class instead of instance, s
| |
| 26 if client_id == CrashClient.FRACAS: | 23 if client_id == CrashClient.FRACAS: |
| 27 return FracasCrashAnalysis | 24 return FracasCrashAnalysis |
| 28 elif client_id == CrashClient.CRACAS: | 25 elif client_id == CrashClient.CRACAS: |
| 29 return CracasCrashAnalysis | 26 return CracasCrashAnalysis |
| 30 elif client_id == CrashClient.CLUSTERFUZZ: | 27 elif client_id == CrashClient.CLUSTERFUZZ: |
| 31 # TODO(katesonia): Define ClusterfuzzCrashAnalysis. | 28 # TODO(katesonia): Define ClusterfuzzCrashAnalysis. |
| 32 return None | 29 return None |
| 33 | 30 |
| 34 return None | 31 return None |
| 35 | 32 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 start_date (str): Only iterate testcases after this date including this | 67 start_date (str): Only iterate testcases after this date including this |
| 71 date, format '%Y-%m-%d'. | 68 date, format '%Y-%m-%d'. |
| 72 end_date (str): Only iterate testcases before this date excluding this date, | 69 end_date (str): Only iterate testcases before this date excluding this date, |
| 73 format '%Y-%m-%d'. | 70 format '%Y-%m-%d'. |
| 74 batch_size (int): The number of crashes to query at one time. | 71 batch_size (int): The number of crashes to query at one time. |
| 75 batch_run (bool): If True, iterate batches of crashes, if | 72 batch_run (bool): If True, iterate batches of crashes, if |
| 76 False, iterate each crash. | 73 False, iterate each crash. |
| 77 | 74 |
| 78 An example is available in crash_printer/print_crash.py. | 75 An example is available in crash_printer/print_crash.py. |
| 79 """ | 76 """ |
| 80 if fields is None: | |
| 81 fields = COMMON_CRASH_FIELDS | |
| 82 | |
| 83 if property_values is None: | 77 if property_values is None: |
| 84 property_values = {} | 78 property_values = {} |
| 85 | 79 |
| 86 query = GetQueryForClient(client_id, property_values, start_date, end_date) | 80 query = GetQueryForClient(client_id, property_values, start_date, end_date) |
| 87 for crash in iterator.Iterate(query, fields, app_id, batch_size=batch_size, | 81 for crash in iterator.Iterate(query, app_id, fields=fields, |
| 82 batch_size=batch_size, | |
| 88 batch_run=batch_run): | 83 batch_run=batch_run): |
| 89 yield crash | 84 yield crash |
| OLD | NEW |