Scott Zawalski | cb2e2b7 | 2012-04-17 12:10:05 -0400 | [diff] [blame^] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | import sys |
| 4 | import common |
| 5 | from autotest_lib.server import frontend |
| 6 | |
| 7 | _AFE = frontend.AFE(debug=False) |
| 8 | |
| 9 | def is_job_complete(job_id): |
| 10 | """ |
| 11 | Check if a job is no longer active. |
| 12 | |
| 13 | @param job_id: afe job id like 123 from 123-scottz |
| 14 | @return True if job is complete and False if it is not |
| 15 | """ |
| 16 | if not _AFE.run('get_jobs', finished=True, id=job_id): |
| 17 | return 1 |
| 18 | |
| 19 | return 0 |
| 20 | |
| 21 | if __name__ == '__main__': |
| 22 | if len(sys.argv) != 2: |
| 23 | print ('Set return status to 0 if job is complete or 1 if it is not.\n' |
| 24 | 'Usage: is_job_complete.py <job_id>') |
| 25 | else: |
| 26 | sys.exit(is_job_complete(sys.argv[1])) |