OLD | NEW |
1 """Database model classes for the scheduler. | 1 """Database model classes for the scheduler. |
2 | 2 |
3 Contains model classes abstracting the various DB tables used by the scheduler. | 3 Contains model classes abstracting the various DB tables used by the scheduler. |
4 These overlap the Django models in basic functionality, but were written before | 4 These overlap the Django models in basic functionality, but were written before |
5 the Django models existed and have not yet been phased out. Some of them | 5 the Django models existed and have not yet been phased out. Some of them |
6 (particularly HostQueueEntry and Job) have considerable scheduler-specific logic | 6 (particularly HostQueueEntry and Job) have considerable scheduler-specific logic |
7 which would probably be ill-suited for inclusion in the general Django model | 7 which would probably be ill-suited for inclusion in the general Django model |
8 classes. | 8 classes. |
9 | 9 |
10 Globals: | 10 Globals: |
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 return n_test_jobs | 885 return n_test_jobs |
886 | 886 |
887 stats = {} | 887 stats = {} |
888 | 888 |
889 rows = _db.execute(""" | 889 rows = _db.execute(""" |
890 SELECT t.test, s.word, t.reason | 890 SELECT t.test, s.word, t.reason |
891 FROM tko_tests AS t, tko_jobs AS j, tko_status AS s | 891 FROM tko_tests AS t, tko_jobs AS j, tko_status AS s |
892 WHERE t.job_idx = j.job_idx | 892 WHERE t.job_idx = j.job_idx |
893 AND s.status_idx = t.status | 893 AND s.status_idx = t.status |
894 AND j.afe_job_id = %s | 894 AND j.afe_job_id = %s |
| 895 ORDER BY t.reason |
895 """ % self.id) | 896 """ % self.id) |
896 | 897 |
897 failed_rows = [r for r in rows if not 'GOOD' in r] | 898 failed_rows = [r for r in rows if not 'GOOD' in r] |
898 | 899 |
899 n_test_jobs = _find_test_jobs(rows) | 900 n_test_jobs = _find_test_jobs(rows) |
900 n_test_jobs_failed = _find_test_jobs(failed_rows) | 901 n_test_jobs_failed = _find_test_jobs(failed_rows) |
901 | 902 |
902 total_executed = len(rows) - n_test_jobs | 903 total_executed = len(rows) - n_test_jobs |
903 total_failed = len(failed_rows) - n_test_jobs_failed | 904 total_failed = len(failed_rows) - n_test_jobs_failed |
904 | 905 |
(...skipping 15 matching lines...) Expand all Loading... |
920 stats['failed_rows'] = '' | 921 stats['failed_rows'] = '' |
921 | 922 |
922 time_row = _db.execute(""" | 923 time_row = _db.execute(""" |
923 SELECT started_time, finished_time | 924 SELECT started_time, finished_time |
924 FROM tko_jobs | 925 FROM tko_jobs |
925 WHERE afe_job_id = %s | 926 WHERE afe_job_id = %s |
926 """ % self.id) | 927 """ % self.id) |
927 | 928 |
928 if time_row: | 929 if time_row: |
929 t_begin, t_end = time_row[0] | 930 t_begin, t_end = time_row[0] |
930 delta = t_end - t_begin | 931 try: |
931 minutes, seconds = divmod(delta.seconds, 60) | 932 delta = t_end - t_begin |
932 hours, minutes = divmod(minutes, 60) | 933 minutes, seconds = divmod(delta.seconds, 60) |
933 stats['execution_time'] = ("%02d:%02d:%02d" % | 934 hours, minutes = divmod(minutes, 60) |
934 (hours, minutes, seconds)) | 935 stats['execution_time'] = ("%02d:%02d:%02d" % |
| 936 (hours, minutes, seconds)) |
| 937 # One of t_end or t_begin are None |
| 938 except TypeError: |
| 939 stats['execution_time'] = '(could not determine)' |
935 else: | 940 else: |
936 stats['execution_time'] = '(none)' | 941 stats['execution_time'] = '(none)' |
937 | 942 |
938 return stats | 943 return stats |
939 | 944 |
940 | 945 |
941 def set_status(self, status, update_queues=False): | 946 def set_status(self, status, update_queues=False): |
942 self.update_field('status',status) | 947 self.update_field('status',status) |
943 | 948 |
944 if update_queues: | 949 if update_queues: |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 def abort_delay_ready_task(self): | 1309 def abort_delay_ready_task(self): |
1305 """Abort the delayed task associated with this job, if any.""" | 1310 """Abort the delayed task associated with this job, if any.""" |
1306 if self._delay_ready_task: | 1311 if self._delay_ready_task: |
1307 # Cancel any pending callback that would try to run again | 1312 # Cancel any pending callback that would try to run again |
1308 # as we are already running. | 1313 # as we are already running. |
1309 self._delay_ready_task.abort() | 1314 self._delay_ready_task.abort() |
1310 | 1315 |
1311 | 1316 |
1312 def __str__(self): | 1317 def __str__(self): |
1313 return '%s-%s' % (self.id, self.owner) | 1318 return '%s-%s' % (self.id, self.owner) |
OLD | NEW |