-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_results.py
36 lines (30 loc) · 1017 Bytes
/
get_results.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# python get_results.py
import csv
import sys
import cloud_setup
def write_results(results, results_file):
header_line = None
with open(results_file, "w") as f:
writer = csv.writer(f)
for result in results:
if not header_line:
header_line = result.keys()
writer.writerow(header_line)
output_line = []
for col in header_line:
output_line.append(result[col])
writer.writerow(output_line)
if __name__ == "__main__":
# Validate command-line arguments
if len(sys.argv) == 3:
job = sys.argv[1]
sdb, dom = cloud_setup.setup_sdb_domain(job)
rs = dom.select('select * from `%s`' % job)
write_results(rs, sys.argv[2])
elif len(sys.argv) == 2:
print "No outfile specified: dumping to stdout"
cloud_setup.dump_sdb_domain(sys.argv[1])
exit(0)
else:
print "Usage: python get_results.py jobname [output_file]"
exit(1)