Пример #1
0
errors = []
stage = -1

try:

    # remove existing compilation results
    stage = 0
    print("Stage {}: {}".format(stage, "remove existing compilation results"))
    shutil.rmtree(work_dir, ignore_errors=True)
    os.makedirs(work_dir)

    # unzip the code
    stage = 1
    print("Stage {}: {}".format(stage, "unzip the code"))
    compile_utils.unzip(source_dir, unzipped_dir)

    # find and copy the root of the client
    stage = 2
    print("Stage {}: {}".format(stage, "find and copy the root of the client"))
    compile_utils.copy_from_root(unzipped_dir, compile_dir, 'controller.py',
                                 -1)

    # compile (syntax check)
    stage = 3
    print("Stage {}: {}".format(stage, "compile (syntax check)"))
    current_uid = os.geteuid()
    compile_utils.recursively_change_owner(work_dir, 2016)
    os.seteuid(2016)
    try:
        compile_done = compile_utils.compile_py3(compile_dir)
root_dir = '/compile'

source_dir = root_dir + '/code.zip'
unzipped_dir = root_dir + '/unzipped'
compile_dir = root_dir + '/compiled/code'
log_dir = root_dir + '/log'

errors = []
stage = -1

try:

    # unzip the code
    stage = 0
    compile_utils.unzip(source_dir, unzipped_dir)

    # remove existing compilation results
    stage = 1
    shutil.rmtree(compile_dir, ignore_errors=True)

    # find main.cpp and copy the root
    stage = 2
    compile_utils.copy_from_root(unzipped_dir, compile_dir, 'main.cpp', -1)

    # compile

    current_uid = os.geteuid()
    compile_utils.recursively_change_owner(compile_dir, 2016)
    os.seteuid(2016)