Ejemplo n.º 1
0
def run_program(config, filepath):
    classpath = str(filepath).strip(filepath.name)
    classfile = filepath.name.strip(".java")
    cmd = 'java  {}'.format(classfile)
    process = open_process(cmd, cwd=classpath, stdin=PIPE, stdout=PIPE, stderr=PIPE)
    st_output, st_error = process.communicate(bytes(config.input, 'UTF-8'), timeout = 30)
    code = process.returncode
    return (st_output, st_error, code)
Ejemplo n.º 2
0
def compile_file(config, filepath):
    cmd = 'javac "{}"'.format(str(filepath))
    process = open_process(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
    st_output, st_error = process.communicate(timeout = 30)
    code = process.returncode
    return (st_output, st_error, code)