[Infer][scripts] Fix crash when stats.json does not exist

master
Sam Blackshear 10 years ago
parent 0b42f9cf06
commit f5f005a720

@ -617,6 +617,11 @@ class Infer:
"""Print timing information to infer_out/stats.json"""
stats_path = os.path.join(self.args.infer_out, utils.STATS_FILENAME)
# capture and compile mode do not create stats.json
if not os.path.isfile(stats_path):
with open(stats_path, 'w') as stats_file:
json.dump(self.stats, stats_file, indent=2)
with open(stats_path, 'r+') as stats_file:
file_stats = json.load(stats_file)
self.stats['int'].update(file_stats)
@ -666,6 +671,7 @@ class Infer:
self.timing['total'] = elapsed
self.save_stats()
if not self.args.analyzer in [COMPILE, CAPTURE]:
procs_total = self.stats['int']['procedures']
files_total = self.stats['int']['files']
procs_str = utils.get_plural('procedure', procs_total)

Loading…
Cancel
Save