Beispiel #1
0
def compile_source(env, **kwargs):
    env.update(dict(
        source_file=env['remote_source_file'],
        out_file=env['binary_file'],
        compiler='system-gcc',
        job_type='compile'))
    return run_sioworkers_job(env)
Beispiel #2
0
def compile_source(env, **kwargs):
    env.update(
        dict(source_file=env['remote_source_file'],
             out_file=env['binary_file'],
             compiler='system-gcc',
             job_type='compile'))
    return run_sioworkers_job(env)
Beispiel #3
0
def compile(env, **kwargs):
    """Compiles source file on the remote machine and returns name of
       the executable that may be ran

       USES
          * env['source_file'] - source file name
          * env['language'] - if ``env['compiler']`` is not set and
            ``env['language']`` is, the compiler is set to ``'default-' +
            env['language']``.
          * the entire ``env`` is also passed to the ``compile`` job

       PRODUCES
          * env['compilation_result'] - may be OK if the file compiled
            successfully or CE otherwise.
          * env['compiled_file'] - exists if and only if
            env['compilation_result'] is set to OK and contains compiled
            binary path
          * env['compilation_message'] - contains compiler stdout and stderr
    """

    compilation_job = env.copy()
    compilation_job['job_type'] = 'compile'
    compilation_job['out_file'] = _make_filename(env, 'exe')
    if 'language' in env and 'compiler' not in env:
        compilation_job['compiler'] = 'default-' + env['language']

    new_env = run_sioworkers_job(compilation_job)

    env['compiled_file'] = compilation_job['out_file']
    env['compilation_message'] = new_env.get('compiler_output', '')
    env['compilation_result'] = new_env.get('result_code', 'CE')
    return env
Beispiel #4
0
def compile(env, **kwargs):
    """Compiles source file on the remote machine and returns name of
       the executable that may be ran

       USES
          * env['source_file'] - source file name
          * env['language'] - if ``env['compiler']`` is not set and
            ``env['language']`` is, the compiler is set to ``'default-' +
            env['language']``.
          * the entire ``env`` is also passed to the ``compile`` job

       PRODUCES
          * env['compilation_result'] - may be OK if the file compiled
            successfully or CE otherwise.
          * env['compiled_file'] - exists if and only if
            env['compilation_result'] is set to OK and contains compiled
            binary path
          * env['compilation_message'] - contains compiler stdin and stdout
    """

    compilation_job = env.copy()
    compilation_job["job_type"] = "compile"
    compilation_job["out_file"] = _make_filename(env, "exe")
    if "language" in env and "compiler" not in env:
        compilation_job["compiler"] = "default-" + env["language"]

    new_env = run_sioworkers_job(compilation_job)

    env["compiled_file"] = compilation_job["out_file"]
    env["compilation_message"] = new_env.get("compiler_output", "")
    env["compilation_result"] = new_env.get("result_code", "CE")
    return env
Beispiel #5
0
def compile(env, **kwargs):
    """Compiles source file on the remote machine and returns name of
       the executable that may be ran

       USES
          * env['source_file'] - source file name
          * env['language'] - if ``env['compiler']`` is not set and
            ``env['language']`` is, the compiler is set to ``'default-' +
            env['language']``.
          * the entire ``env`` is also passed to the ``compile`` job

       PRODUCES
          * env['compilation_result'] - may be OK if the file compiled
            successfully or CE otherwise.
          * env['compiled_file'] - exists if and only if
            env['compilation_result'] is set to OK and contains compiled
            binary path
          * env['compilation_message'] - contains compiler stdin and stdout
    """

    compilation_job = env.copy()
    compilation_job['job_type'] = 'compile'
    compilation_job['out_file'] = _make_filename(env, 'exe')
    if 'language' in env and 'compiler' not in env:
        compilation_job['compiler'] = 'default-' + env['language']

    new_env = run_sioworkers_job(compilation_job)

    env['compiled_file'] = compilation_job['out_file']
    env['compilation_message'] = new_env.get('compiler_output', '')
    env['compilation_result'] = new_env.get('result_code', 'CE')
    return env
Beispiel #6
0
 def test_sioworkers_bindings(self):
     env = run_sioworkers_job(dict(job_type='ping', ping='e1'))
     self.assertEqual(env.get('pong'), 'e1')
     envs = run_sioworkers_jobs(
         dict(key1=dict(job_type='ping', ping='e1'),
              key2=dict(job_type='ping', ping='e2')))
     self.assertEqual(envs['key1'].get('pong'), 'e1')
     self.assertEqual(envs['key2'].get('pong'), 'e2')
     self.assertEqual(len(envs), 2)
Beispiel #7
0
 def test_sioworkers_bindings(self):
     env = run_sioworkers_job(dict(job_type='ping', ping='e1'))
     self.assertEqual(env.get('pong'), 'e1')
     envs = run_sioworkers_jobs(
             dict(key1=dict(job_type='ping', ping='e1'),
                  key2=dict(job_type='ping', ping='e2')))
     self.assertEqual(envs['key1'].get('pong'), 'e1')
     self.assertEqual(envs['key2'].get('pong'), 'e2')
     self.assertEqual(len(envs), 2)
Beispiel #8
0
    def _make_ins(self, re_string):
        env = self._find_and_compile('ingen')
        if env and not self.use_make:
            env['job_type'] = 'ingen'
            env['exe_file'] = env['compiled_file']
            env['re_string'] = re_string
            env['use_sandboxes'] = self.use_sandboxes
            env['collected_files_path'] = _make_filename(self.env, 'in')

            renv = run_sioworkers_job(env)
            get_client().delete_file(env['compiled_file'])
            return renv['collected_files']
        else:
            return {}
Beispiel #9
0
    def _make_ins(self, re_string):
        env = self._find_and_compile('ingen')
        if env and not self.use_make:
            env['job_type'] = 'ingen'
            env['task_priority'] = TASK_PRIORITY
            env['exe_file'] = env['compiled_file']
            env['re_string'] = re_string
            env['use_sandboxes'] = self.use_sandboxes
            env['collected_files_path'] = \
                _make_filename_in_job_dir(self.env, 'in')

            renv = run_sioworkers_job(env)
            get_client().delete_file(env['compiled_file'])
            return renv['collected_files']

        return {}
Beispiel #10
0
    def _make_ins(self, re_string):
        env = self._find_and_compile('ingen')
        if env and not self.use_make:
            env['job_type'] = 'ingen'
            env['task_priority'] = TASK_PRIORITY
            env['exe_file'] = env['compiled_file']
            env['re_string'] = re_string
            env['use_sandboxes'] = self.use_sandboxes
            env['collected_files_path'] = \
                _make_filename_in_job_dir(self.env, 'in')

            renv = run_sioworkers_job(env)
            get_client().delete_file(env['compiled_file'])
            return renv['collected_files']

        return {}
Beispiel #11
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
Beispiel #12
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
Beispiel #13
0
def run(env, **kwargs):
    env.update(dict(
        exe_file=env['binary_file'],
        check_output=True,
        job_type='unsafe-exec'))
    return run_sioworkers_job(env)
Beispiel #14
0
def run(env, **kwargs):
    env.update(
        dict(exe_file=env['binary_file'],
             check_output=True,
             job_type='unsafe-exec'))
    return run_sioworkers_job(env)