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

Side by Side Diff: scripts/slave/recipe_modules/swarming/resources/collect_gtest_task.py

Issue 2413553002: Log more when loading shard output.json fails (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import json 6 import json
7 import optparse 7 import optparse
8 import os 8 import os
9 import shutil 9 import shutil
10 import subprocess 10 import subprocess
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 path = os.path.join(output_dir, str(index), 'output.json') 105 path = os.path.join(output_dir, str(index), 'output.json')
106 try: 106 try:
107 filesize = os.stat(path).st_size 107 filesize = os.stat(path).st_size
108 if filesize > OUTPUT_JSON_SIZE_LIMIT: 108 if filesize > OUTPUT_JSON_SIZE_LIMIT:
109 print >> sys.stderr, 'output.json is %d bytes. Max size is %d' % ( 109 print >> sys.stderr, 'output.json is %d bytes. Max size is %d' % (
110 filesize, OUTPUT_JSON_SIZE_LIMIT) 110 filesize, OUTPUT_JSON_SIZE_LIMIT)
111 return None 111 return None
112 112
113 with open(path) as f: 113 with open(path) as f:
114 return json.load(f) 114 return json.load(f)
115 except (IOError, ValueError, OSError): 115 except (IOError, ValueError, OSError) as e:
116 print >> sys.stderr, 'Missing or invalid gtest JSON file: %s' % path 116 print >> sys.stderr, 'Missing or invalid gtest JSON file: %s' % path
117 print >> sys.stderr, '%s: %s' % (type(e).__name__, e)
117 return None 118 return None
118 119
119 120
120 def merge_list_of_dicts(left, right): 121 def merge_list_of_dicts(left, right):
121 """Merges dicts left[0] with right[0], left[1] with right[1], etc.""" 122 """Merges dicts left[0] with right[0], left[1] with right[1], etc."""
122 output = [] 123 output = []
123 for i in xrange(max(len(left), len(right))): 124 for i in xrange(max(len(left), len(right))):
124 left_dict = left[i] if i < len(left) else {} 125 left_dict = left[i] if i < len(left) else {}
125 right_dict = right[i] if i < len(right) else {} 126 right_dict = right[i] if i < len(right) else {}
126 merged_dict = left_dict.copy() 127 merged_dict = left_dict.copy()
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 'failed to process gtest output JSON', traceback.format_exc()) 201 'failed to process gtest output JSON', traceback.format_exc())
201 202
202 finally: 203 finally:
203 shutil.rmtree(task_output_dir, ignore_errors=True) 204 shutil.rmtree(task_output_dir, ignore_errors=True)
204 205
205 return exit_code 206 return exit_code
206 207
207 208
208 if __name__ == '__main__': 209 if __name__ == '__main__':
209 sys.exit(main(sys.argv[1:])) 210 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698