| OLD | NEW |
| 1 #!/usr/bin/python -u | 1 #!/usr/bin/python -u |
| 2 # Copyright 2007-2008 Martin J. Bligh <mbligh@google.com>, Google Inc. | 2 # Copyright 2007-2008 Martin J. Bligh <mbligh@google.com>, Google Inc. |
| 3 # Released under the GPL v2 | 3 # Released under the GPL v2 |
| 4 | 4 |
| 5 """ | 5 """ |
| 6 Run an control file through the server side engine | 6 Run an control file through the server side engine |
| 7 """ | 7 """ |
| 8 | 8 |
| 9 import sys, os, re, traceback, signal, time, logging, getpass | 9 import sys, os, re, traceback, signal, time, logging, getpass |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 # Implement SIGTERM handler | 47 # Implement SIGTERM handler |
| 48 def handle_sigterm(signum, frame): | 48 def handle_sigterm(signum, frame): |
| 49 if pid_file_manager: | 49 if pid_file_manager: |
| 50 pid_file_manager.close_file(1, signal.SIGTERM) | 50 pid_file_manager.close_file(1, signal.SIGTERM) |
| 51 os.killpg(os.getpgrp(), signal.SIGKILL) | 51 os.killpg(os.getpgrp(), signal.SIGKILL) |
| 52 | 52 |
| 53 # Set signal handler | 53 # Set signal handler |
| 54 signal.signal(signal.SIGTERM, handle_sigterm) | 54 signal.signal(signal.SIGTERM, handle_sigterm) |
| 55 | 55 |
| 56 # Ignore SIGTTOU's generated by output from forked children. |
| 57 signal.signal(signal.SIGTTOU, signal.SIG_IGN) |
| 58 |
| 56 # Server side tests that call shell scripts often depend on $USER being set | 59 # Server side tests that call shell scripts often depend on $USER being set |
| 57 # but depending on how you launch your autotest scheduler it may not be set. | 60 # but depending on how you launch your autotest scheduler it may not be set. |
| 58 os.environ['USER'] = getpass.getuser() | 61 os.environ['USER'] = getpass.getuser() |
| 59 | 62 |
| 60 if parser.options.machines: | 63 if parser.options.machines: |
| 61 machines = parser.options.machines.replace(',', ' ').strip().split() | 64 machines = parser.options.machines.replace(',', ' ').strip().split() |
| 62 else: | 65 else: |
| 63 machines = [] | 66 machines = [] |
| 64 machines_file = parser.options.machines_file | 67 machines_file = parser.options.machines_file |
| 65 label = parser.options.label | 68 label = parser.options.label |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 # an 'abort' and return 1. | 232 # an 'abort' and return 1. |
| 230 exit_code = 1 | 233 exit_code = 1 |
| 231 finally: | 234 finally: |
| 232 if pid_file_manager: | 235 if pid_file_manager: |
| 233 pid_file_manager.close_file(exit_code) | 236 pid_file_manager.close_file(exit_code) |
| 234 sys.exit(exit_code) | 237 sys.exit(exit_code) |
| 235 | 238 |
| 236 | 239 |
| 237 if __name__ == '__main__': | 240 if __name__ == '__main__': |
| 238 main() | 241 main() |
| OLD | NEW |