Exemple #1
0
    def _compile(self, filename, prog_name, ext, out_name=None):
        client = get_client()
        source_name = '%s.%s' % (prog_name, ext)
        ft_source_name = client.put_file(_make_filename(self.env, source_name),
                filename)

        if not out_name:
            out_name = _make_filename(self.env, '%s.e' % prog_name)

        compilation_job = self.env.copy()
        compilation_job['job_type'] = 'compile'
        compilation_job['source_file'] = ft_source_name
        compilation_job['out_file'] = out_name
        lang = ext
        compilation_job['language'] = lang
        if self.use_sandboxes:
            prefix = 'default'
        else:
            prefix = 'system'
        compilation_job['compiler'] = prefix + '-' + lang
        if not self.use_make and self.prog_archive:
            compilation_job['additional_archive'] = self.prog_archive

        add_extra_files(compilation_job, self.problem,
                additional_args=self.extra_compilation_args)
        new_env = run_sioworkers_job(compilation_job)
        client.delete_file(ft_source_name)

        compilation_message = new_env.get('compiler_output', '')
        compilation_result = new_env.get('result_code', 'CE')
        if compilation_result != 'OK':
            logger.warning("%s: compilation of file %s failed with code %s",
                    self.filename, filename, compilation_result)
            logger.warning("%s: compiler output: %r", self.filename,
                    compilation_message)

            raise ProblemPackageError(_("Compilation of file %(filename)s "
                "failed. Compiler output: %(output)s") % {
                    'filename': filename, 'output': compilation_message})

        # TODO Remeber about 'exec_info' when Java support is introduced.
        new_env['compiled_file'] = new_env['out_file']
        return new_env
Exemple #2
0
 def _run_compilation_job(self, ext, ft_source_name, out_name):
     compilation_job = self.env.copy()
     compilation_job['job_type'] = 'compile'
     compilation_job['task_priority'] = TASK_PRIORITY
     compilation_job['source_file'] = ft_source_name
     compilation_job['out_file'] = out_name
     lang = ext
     compilation_job['language'] = lang
     if self.use_sandboxes:
         prefix = 'default'
     else:
         prefix = 'system'
     compilation_job['compiler'] = prefix + '-' + lang
     if not self.use_make and self.prog_archive:
         compilation_job['additional_archive'] = self.prog_archive
     add_extra_files(compilation_job, self.problem,
                     additional_args=self.extra_compilation_args)
     new_env = run_sioworkers_job(compilation_job)
     return new_env
Exemple #3
0
 def fill_evaluation_environ(self, environ, submission, **kwargs):
     super(SinolProblemController,
           self).fill_evaluation_environ(environ, submission, **kwargs)
     add_extra_files(environ, self.problem)
Exemple #4
0
 def fill_evaluation_environ(self, environ, submission, **kwargs):
     super(SinolProblemController, self).fill_evaluation_environ(environ, submission, **kwargs)
     add_extra_files(environ, self.problem)