# 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) finally: os.seteuid(current_uid) os.chown(compile_dir, current_uid, current_uid) # make archive stage = 4 print("Stage {}: {}".format(stage, "make archive")) shutil.copy2('/utils/run.sh', work_dir) shutil.make_archive(root_dir + '/compiled/compiled', 'zip', work_dir) # remove compilation results stage = 5
# 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) stage = 3 try: compile_utils.compile_cpp(compile_dir) finally: os.seteuid(current_uid) os.chown(compile_dir, current_uid, current_uid) # make archive stage = 4 shutil.make_archive(root_dir + '/compiled/compiled', 'zip', compile_dir) # remove compilation results stage = 5