Beispiel #1
0
    def accept_results(self, subtask_id, result_files):
        super(LuxTask, self).accept_results(subtask_id, result_files)
        num_start = self.subtasks_given[subtask_id]['start_task']
        for tr_file in result_files:
            if has_ext(tr_file, ".flm"):
                self.collected_file_names[num_start] = tr_file
                self.counting_nodes[self.subtasks_given[subtask_id]
                                    ['node_id']].accept()
                self.num_tasks_received += 1
            elif not has_ext(tr_file, '.log'):
                self.subtasks_given[subtask_id]['preview_file'] = tr_file
                self._update_preview(tr_file, num_start)

        if self.num_tasks_received == self.total_tasks:
            if self.verificator.advanced_verification\
                    and os.path.isfile(self.__get_test_flm()):
                self.__generate_final_flm_advanced_verification()
            else:
                self.__generate_final_flm()
Beispiel #2
0
    def test_has_ext(self):
        file_names = ["file.ext", "file.dde", "file.abc", "file.ABC", "file.Abc", "file.DDE",
                       "file.XYZ", "file.abC"]
        files = [self.temp_file_name(f) for f in file_names]
        for f in files:
            with open(f, 'w'):
                pass
        assert has_ext(file_names[0], ".ext")
        assert has_ext(file_names[0], ".EXT")
        assert not has_ext(file_names[0], ".EXT", True)
        assert has_ext(file_names[0], ".ext", True)
        assert not has_ext(file_names[0], ".exr")

        assert len([x for x in file_names if has_ext(x, ".abc")]) == 4
        assert len([x for x in file_names if has_ext(x, ".abc", True)]) == 1

        assert has_ext(file_names[6], ".xyz")
        assert not has_ext(file_names[6], ".xyz", True)
Beispiel #3
0
    def after_test(self, results, tmp_dir):
        return_data = dict()
        if not results or not results.get("data"):
            return return_data

        for filename in results["data"]:
            if not has_ext(filename, ".log"):
                continue

            with open(filename, "r") as f:
                log_content = f.read()

            log_analyser.make_log_analyses(log_content, return_data)

        return return_data
Beispiel #4
0
    def _check_files(self, subtask_id, subtask_info, tr_files, task):
        if len(tr_files) == 0:
            self.ver_states[subtask_id] = SubtaskVerificationState.WRONG_ANSWER
            return

        for tr_file in tr_files:
            tr_file = os.path.normpath(tr_file)
            if has_ext(tr_file, '.FLM'):
                if self.advanced_verification:
                    if not os.path.isfile(self.test_flm):
                        logger.warning("Advanced verification set, but couldn't find test result!")
                        logger.warning("Skipping verification")
                    else:
                        if not self.merge_flm_files(tr_file, task, self.test_flm):
                            logger.info("Subtask " + str(subtask_id) + " rejected.")
                            self.ver_states[subtask_id] = SubtaskVerificationState.WRONG_ANSWER
                            return
                self.ver_states[subtask_id] = SubtaskVerificationState.VERIFIED
        if self.ver_states.get(subtask_id) != SubtaskVerificationState.VERIFIED:
            self.ver_states[subtask_id] = SubtaskVerificationState.WRONG_ANSWER
Beispiel #5
0
 def _update_preview(self, new_chunk_file_path, chunk_num):
     self.num_add += 1
     if has_ext(new_chunk_file_path, ".exr"):
         self._update_preview_from_exr(new_chunk_file_path)
     else:
         self.__update_preview_from_pil_file(new_chunk_file_path)