Beispiel #1
0
def init():
    logger.info("Initializing...")

    # Escalate permissions to root (sudo) if not ran as root
    # This is required for creating the chroot jails and running the solutions.
    escalate_permissions()

    # Set the current working dir to the root of the grader
    # not matter when we run the script from
    root_dir = os.path.dirname(os.path.abspath(__file__))
    if os.getcwd() != root_dir:
        logger.info("Setting working directory to '{}'.".format(root_dir))
        os.chdir(root_dir)

    # Create the sandbox directories for each of the workers and prepare them
    # to be chrooted (mounting /bin, /dev, /lib and similar directories inside)
    Workers.init()

    logger.info("Initialization completed successfully!")