Exemplo n.º 1
0
 def _compile(self):
     return self._compile_raw(
         self.request,
         _configure_cmd(
             self.request.lang.compile,
             'main.%s' % self.request.lang.extension
         ),
         self.executor,
         self.result_dir
     )
Exemplo n.º 2
0
 def _compile(self):
     return self._compile_raw(
         self.request,
         _configure_cmd(
             self.request.problem.reference.lang_ref.compile,
             self.request.problem.reference.name
         ),
         self.executor,
         self.problem_dir
     )
Exemplo n.º 3
0
 def _run(self):
     self._solve_raw(self.request,
                     _configure_cmd(
                         self.request.problem.reference.lang_ref.run
                         or ['main'], self.request.problem.reference.name),
                     self.executor,
                     self.problem_dir.joinpath('input'),
                     self.problem_dir.joinpath('output'),
                     self.problem_dir.joinpath('.error'),
                     self.problem_dir.joinpath('output'),
                     teacher=True)
Exemplo n.º 4
0
 def _run(self):
     self._solve_raw(
         self.request,
         _configure_cmd(
             self.request.lang.run,
             'main.%s' % self.request.lang.extension
         ),
         self.executor,
         self.problem_dir.joinpath('input'),
         self.result_dir.joinpath('output'),
         self.result_dir.joinpath('.error'),
         self.problem_dir.joinpath('output'),
     )
Exemplo n.º 5
0
    def _run(self):
        cmd_base = _configure_cmd(
            self.request.problem.reference.lang_ref.run or ['main'],
            self.request.problem.reference.name
        )
        logger.opt(ansi=True).info('<red>{}</red> - {}', 'RUNNING', cmd_base)

        for id, case, subcase in self.request:
            if not case.size:
                logger.opt(ansi=True).warning(
                    '{course.name}<b,e,>:</b,e,>{problem.id}<b,e,>:</b,e,>{case.id} - '
                    'Cannot generate input file, property '
                    '"<b,e,>size</b,e,>" not specified',
                    case=case, problem=self.request.problem, course=self.request.course
                )
                self.request[id].status = ExecutorStatus.IGNORE
                self.request[id].message = 'Test skipped'
                self.request[id].console = 'Cannot generate input file, property "size" not specified'
                self.request.event_execute_test.close_event.trigger(
                    self.request, self.request[id]
                )
                continue

            inn = None
            out = self.problem_dir.joinpath('input', subcase.id)
            err = self.problem_dir.joinpath('.error', subcase.id)
            cmd = cmd_base + subcase.generate_input_args()

            logger.opt(ansi=True).info(
                '{course.name}<b,g,>:</b,g,>{problem.id}<b,g,>:</b,g,>{case.id} - {}',
                cmd, case=subcase, problem=self.request.problem, course=self.request.course
            )
            self.request[id].status = ExecutorStatus.RUNNING
            self.request.event_execute_test.open_event.trigger(
                self.request, self.request[id]
            )
            with self.executor.set_streams(stdin=inn, stdout=out, stderr=err) as ex:
                result = ex.run(cmd).register(id)

            self.request[id] = result
            self.request[id] = add_cmd_to_result(id, self.request[id])
            self.request.event_execute_test.close_event.trigger(
                self.request, self.request[id]
            )
Exemplo n.º 6
0
    def _compile_cmd(self):
        if self.request.type is ProcessRequestType.SOLVE:
            pipeline = self.request.lang.compile
            name = 'main.%s' % self.request.lang.extension

        elif self.request.type in (ProcessRequestType.GENERATE_INPUT,
                                   ProcessRequestType.GENERATE_OUTPUT):
            if self.request.problem.reference:
                pipeline = self.request.problem.reference.lang_ref.compile
                name = self.request.problem.reference.name
            else:
                pipeline, name = None, None
        else:
            logger.error('Invalid action type')
            raise FatalException('Invalid action type {}', self.request.type)

        if not pipeline:
            return None

        return _configure_cmd(pipeline, name)