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

Side by Side Diff: appengine/findit/util_scripts/crash_queries/delta_test/delta_util.py

Issue 2432203003: [Predator] Run predator. (Closed)
Patch Set: Fix nits. 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 """Util functions for git repository processing.""" 5 """Util functions for git repository processing."""
6 6
7 import base64 7 import base64
8 import hashlib 8 import hashlib
9 import json 9 import json
10 import logging 10 import logging
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 # TODO(crbug.com/662540): Add unittests. 55 # TODO(crbug.com/662540): Add unittests.
56 def EnsureDirExists(path): # pragma: no cover 56 def EnsureDirExists(path): # pragma: no cover
57 directory = os.path.dirname(path) 57 directory = os.path.dirname(path)
58 if os.path.exists(directory): 58 if os.path.exists(directory):
59 return 59 return
60 60
61 os.makedirs(directory) 61 os.makedirs(directory)
62 62
63 63
64 # TODO(crbug.com/662540): Add unittests. 64 # TODO(crbug.com/662540): Add unittests.
65 def FlushResult(result, result_path): # pragma: no cover 65 def FlushResult(result, result_path, serializer=pickle): # pragma: no cover
66 logging.info('\nFlushing results to %s', result_path) 66 logging.info('\nFlushing results to %s', result_path)
67 EnsureDirExists(result_path) 67 EnsureDirExists(result_path)
68 with open(result_path, 'wb') as f: 68 with open(result_path, 'wb') as f:
69 pickle.dump(result, f) 69 serializer.dump(result, f)
70 70
71 71
72 # TODO(crbug.com/662540): Add unittests. 72 # TODO(crbug.com/662540): Add unittests.
73 def PrintDelta(deltas, crash_num): # pragma: no cover 73 def PrintDelta(deltas, crash_num): # pragma: no cover
74 logging.info(('\n+++++++++++++++++++++' 74 logging.info(('\n+++++++++++++++++++++'
75 '\nDelta on %d crashes ' 75 '\nDelta on %d crashes '
76 '\n+++++++++++++++++++++'), crash_num) 76 '\n+++++++++++++++++++++'), crash_num)
77 77
78 if not deltas: 78 if not deltas:
79 logging.info('Two sets of results are the same.') 79 logging.info('Two sets of results are the same.')
(...skipping 20 matching lines...) Expand all
100 for crash_id, delta in deltas.iteritems(): 100 for crash_id, delta in deltas.iteritems():
101 delta_str_dict = delta.delta_str_dict 101 delta_str_dict = delta.delta_str_dict
102 feedback_url = _FEEDBACK_URL_TEMPLATE % crash_id 102 feedback_url = _FEEDBACK_URL_TEMPLATE % crash_id
103 f.write('%s, "%s", "%s", "%s", "%s"\n' % ( 103 f.write('%s, "%s", "%s", "%s", "%s"\n' % (
104 feedback_url, 104 feedback_url,
105 _EncodeStr(delta_str_dict.get('project', '')), 105 _EncodeStr(delta_str_dict.get('project', '')),
106 _EncodeStr(delta_str_dict.get('components', '')), 106 _EncodeStr(delta_str_dict.get('components', '')),
107 _EncodeStr(delta_str_dict.get('cls', '')), 107 _EncodeStr(delta_str_dict.get('cls', '')),
108 _EncodeStr(delta_str_dict.get('regression_range', '')) 108 _EncodeStr(delta_str_dict.get('regression_range', ''))
109 )) 109 ))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698