1 | #!/usr/bin/env python2
|
2 | """
|
3 | tsv_stream.py
|
4 |
|
5 | Turn a log stream into a TSV file.
|
6 |
|
7 | Commands:
|
8 |
|
9 | | HEADER status elapsed_secs test test_HREF
|
10 |
|
11 | | ROW test=asdl/format_test.py test_HREF=asdl/format_test.py.txt
|
12 |
|
13 | | ADD status=0 elapsed_secs=0.01
|
14 | # time-tsv can emit this format
|
15 |
|
16 |
|
17 | Later the header could be typed YTSV, for justification like
|
18 |
|
19 | | HEADER (status Int, elapsed_secs Float, test Str, test_HREF Str)
|
20 |
|
21 |
|
22 | """
|
23 | from __future__ import print_function
|
24 |
|
25 | import sys
|
26 |
|
27 |
|
28 | def main(argv):
|
29 | for i, line in enumerate(sys.stdin):
|
30 | if i == 0:
|
31 | print('header')
|
32 |
|
33 | print(line.strip())
|
34 |
|
35 | sys.stdout.flush()
|
36 |
|
37 |
|
38 | if __name__ == '__main__':
|
39 | try:
|
40 | main(sys.argv)
|
41 | except RuntimeError as e:
|
42 | print('FATAL: %s' % e, file=sys.stderr)
|
43 | sys.exit(1)
|