OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 """Outputs on both stderr and stdout.""" | |
7 | |
8 import re | |
9 import sys | |
10 import time | |
11 | |
12 | |
13 def main(): | |
14 for command in sys.argv[1:]: | |
15 if re.match(r'^[0-9\.]+$', command): | |
16 time.sleep(float(command)) | |
17 continue | |
18 | |
19 if command.startswith('out_'): | |
20 pipe = sys.stdout | |
21 elif command.startswith('err_'): | |
22 pipe = sys.stderr | |
23 else: | |
24 return 1 | |
25 | |
26 command = command[4:] | |
27 if command == 'print': | |
28 pipe.write('printing') | |
29 elif command == 'sleeping': | |
30 pipe.write('Sleeping.\n') | |
31 elif command == 'slept': | |
32 pipe.write('Slept.\n') | |
33 elif command == 'lf': | |
34 pipe.write('\n') | |
35 elif command == 'flush': | |
36 pipe.flush() | |
37 else: | |
38 return 1 | |
39 return 0 | |
40 | |
41 | |
42 if __name__ == '__main__': | |
43 sys.exit(main()) | |
OLD | NEW |