| 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 """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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 | 51 |
| 52 def EnsureDirExists(path): | 52 def EnsureDirExists(path): |
| 53 directory = os.path.dirname(path) | 53 directory = os.path.dirname(path) |
| 54 if os.path.exists(directory): | 54 if os.path.exists(directory): |
| 55 return | 55 return |
| 56 | 56 |
| 57 os.makedirs(directory) | 57 os.makedirs(directory) |
| 58 | 58 |
| 59 | 59 |
| 60 def FlushResult(result, result_path): | 60 def FlushResult(result, result_path, serializer=pickle): |
| 61 logging.info('\nFlushing results to %s', result_path) | 61 logging.info('\nFlushing results to %s', result_path) |
| 62 EnsureDirExists(result_path) | 62 EnsureDirExists(result_path) |
| 63 with open(result_path, 'wb') as f: | 63 with open(result_path, 'wb') as f: |
| 64 pickle.dump(result, f) | 64 serializer.dump(result, f) |
| 65 | 65 |
| 66 | 66 |
| 67 def PrintDelta(deltas, crash_num): | 67 def PrintDelta(deltas, crash_num): |
| 68 logging.info(('\n+++++++++++++++++++++' | 68 logging.info(('\n+++++++++++++++++++++' |
| 69 '\nDelta on %d crashes ' | 69 '\nDelta on %d crashes ' |
| 70 '\n+++++++++++++++++++++'), crash_num) | 70 '\n+++++++++++++++++++++'), crash_num) |
| 71 | 71 |
| 72 if not deltas: | 72 if not deltas: |
| 73 logging.info('Two sets of results are the same.') | 73 logging.info('Two sets of results are the same.') |
| 74 return | 74 return |
| (...skipping 17 matching lines...) Expand all Loading... |
| 92 for crash_id, delta in deltas.iteritems(): | 92 for crash_id, delta in deltas.iteritems(): |
| 93 delta_str_dict = delta.delta_str_dict | 93 delta_str_dict = delta.delta_str_dict |
| 94 feedback_url = _FEEDBACK_URL_TEMPLATE % crash_id | 94 feedback_url = _FEEDBACK_URL_TEMPLATE % crash_id |
| 95 f.write('%s, "%s", "%s", "%s", "%s"\n' % ( | 95 f.write('%s, "%s", "%s", "%s", "%s"\n' % ( |
| 96 feedback_url, | 96 feedback_url, |
| 97 _EncodeStr(delta_str_dict.get('project', '')), | 97 _EncodeStr(delta_str_dict.get('project', '')), |
| 98 _EncodeStr(delta_str_dict.get('components', '')), | 98 _EncodeStr(delta_str_dict.get('components', '')), |
| 99 _EncodeStr(delta_str_dict.get('cls', '')), | 99 _EncodeStr(delta_str_dict.get('cls', '')), |
| 100 _EncodeStr(delta_str_dict.get('regression_range', '')) | 100 _EncodeStr(delta_str_dict.get('regression_range', '')) |
| 101 )) | 101 )) |
| OLD | NEW |