source: 2013/30/build_and_write_report_continuously.py @ 4531

Revision 4506, 1.2 KB checked in by tojukarp, 6 years ago (diff)

Jypeli

Line 
1# -*- coding: latin-1 -*-
2"""
3Calls the build_games- and write_report-scripts continuously,
4until ctrl-c is pressed.
5"""
6
7import sys
8from subprocess import *
9import time
10
11
12programs = []
13processes = []
14
15
16def add_program(command_line):
17    global programs
18    global processes
19    programs.append(command_line)
20    processes.append(Popen(command_line, shell=True))
21
22
23def restart_finished_programs():
24    for i in range(len(programs)):
25        return_code = processes[i].poll()
26        if return_code is not None:
27            # the process has finished, restart it
28            processes[i] = Popen(programs[i], shell=True)
29
30
31def main():
32    try:
33        add_program("build_games.py --write-results")
34        # write report expects to find a build result directory, which
35        # is created by the build script. So, lets give the build a head start.
36        time.sleep(5)
37
38        add_program("write_report.py --hide-pong")
39
40        while True:
41            restart_finished_programs()
42            time.sleep(15)
43       
44    except KeyboardInterrupt:
45        pass
46    except Exception, e:
47        print
48        print "NOT SUCCESSFUL:", e
49        return 1
50
51
52if __name__ == '__main__':
53    sys.exit(main())
54
Note: See TracBrowser for help on using the repository browser.