mbligh | 38e9d78 | 2008-05-01 20:49:41 +0000 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | import cgi, os, sys |
| 4 | |
| 5 | page = """\ |
showard | a80823b | 2008-07-24 16:33:35 +0000 | [diff] [blame] | 6 | Status: 302 Found |
mbligh | e0869d0 | 2008-06-04 20:04:28 +0000 | [diff] [blame] | 7 | Content-Type: text/plain |
showard | 77f95db | 2008-07-17 16:59:38 +0000 | [diff] [blame] | 8 | Location: %s\r\n\r |
mbligh | 38e9d78 | 2008-05-01 20:49:41 +0000 | [diff] [blame] | 9 | """ |
| 10 | |
| 11 | # Get access to directories |
| 12 | tko = os.path.dirname(os.path.realpath(os.path.abspath(sys.argv[0]))) |
| 13 | sys.path.insert(0, tko) |
| 14 | |
| 15 | autodir = os.path.abspath(os.path.join(tko, '..')) |
| 16 | |
| 17 | # Define function for retrieving logs |
| 18 | try: |
| 19 | import site_retrieve_logs |
| 20 | retrieve_logs = site_retrieve_logs.retrieve_logs |
| 21 | del site_retrieve_logs |
| 22 | except ImportError: |
| 23 | def retrieve_logs(autodir, job_path): |
| 24 | pass |
| 25 | |
| 26 | # Get form fields |
| 27 | form = cgi.FieldStorage(keep_blank_values=True) |
| 28 | # Retrieve logs |
| 29 | job_path = form['job'].value[1:] |
| 30 | keyval = retrieve_logs(autodir, job_path) |
| 31 | |
| 32 | # Redirect to results page |
| 33 | testname = '' |
| 34 | if 'test' in form: |
| 35 | testname = form['test'].value |
mbligh | e0869d0 | 2008-06-04 20:04:28 +0000 | [diff] [blame] | 36 | full_path = os.path.join(autodir, job_path, form['test'].value) |
| 37 | if not os.path.exists(full_path): |
| 38 | testname = '' |
mbligh | 38e9d78 | 2008-05-01 20:49:41 +0000 | [diff] [blame] | 39 | path = "%s%s" % (form['job'].value, testname) |
| 40 | print page % path |