From db4722b49a13557c4a987893f5455001188d4400 Mon Sep 17 00:00:00 2001 From: Martin Nowack Date: Fri, 31 Jan 2020 13:34:16 +0000 Subject: [klee-stats] Refactor CSV printout in own function --- tools/klee-stats/klee-stats | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'tools') diff --git a/tools/klee-stats/klee-stats b/tools/klee-stats/klee-stats index 5bc00e04..98062d09 100755 --- a/tools/klee-stats/klee-stats +++ b/tools/klee-stats/klee-stats @@ -241,6 +241,20 @@ def grafana(dirs, host_address, port): app.run(host=host_address, port=port) return 0 + +def write_csv(data): + import csv + data = data[0] + c = data.conn.cursor() + sql3_cursor = c.execute("SELECT * FROM stats") + csv_out = csv.writer(sys.stdout) + # write header + csv_out.writerow([d[0] for d in sql3_cursor.description]) + # write data + for result in sql3_cursor: + csv_out.writerow(result) + + def main(): parser = argparse.ArgumentParser( description='output statistics logged by klee', @@ -313,16 +327,7 @@ def main(): data = [LazyEvalList(d) for d in valid_log_files] if args.toCsv: - import csv - data = data[0] - c = data.conn.cursor() - sql3_cursor = c.execute("SELECT * FROM stats") - csv_out = csv.writer(sys.stdout) - # write header - csv_out.writerow([d[0] for d in sql3_cursor.description]) - # write data - for result in sql3_cursor: - csv_out.writerow(result) + write_csv(data) return if len(data) > 1: @@ -372,6 +377,6 @@ def main(): stream = '\n'.join(stream) print(stream) - + if __name__ == '__main__': main() -- cgit 1.4.1