Rev | Line | |
---|
[4506] | 1 | # -*- coding: latin-1 -*- |
---|
| 2 | """ |
---|
| 3 | Calls the build_games- and write_report-scripts continuously, |
---|
| 4 | until ctrl-c is pressed. |
---|
| 5 | """ |
---|
| 6 | |
---|
| 7 | import sys |
---|
| 8 | from subprocess import * |
---|
| 9 | import time |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | programs = [] |
---|
| 13 | processes = [] |
---|
| 14 | |
---|
| 15 | |
---|
| 16 | def 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 | |
---|
| 23 | def 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 | |
---|
| 31 | def 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 | |
---|
| 52 | if __name__ == '__main__': |
---|
| 53 | sys.exit(main()) |
---|
| 54 | |
---|
Note: See
TracBrowser
for help on using the repository browser.