示例#1
0
def setup(working_dir=None):
    """Environment setup
    working_dir: a directory path other than the default directory"""
    # create the top directory and cache file
    logger.debug("Setting up...")
    top_dir = general.get_top_dir(working_dir)
    if not os.path.isdir(top_dir):
        os.makedirs(top_dir)
    # set the working directory according to user input
    rootfs.set_working_dir(working_dir)
    # load the cache
    cache.load()
示例#2
0
文件: prep.py 项目: tern-tools/tern
def setup(working_dir=None):
    """Environment setup
    working_dir: a directory path other than the default directory"""
    # create the top directory and cache file
    logger.debug("Setting up...")
    top_dir = general.get_top_dir(working_dir)
    if not os.path.isdir(top_dir):
        os.makedirs(top_dir)
    # set the working directory according to user input
    rootfs.set_working_dir(working_dir)
    # load the cache
    cache.load()
    # required to run in a container natively on Windows
    fs_hash_path = pkg_resources.resource_filename("tern", "tools/fs_hash.sh")
    rootfs.root_command(["chmod", "+x", fs_hash_path])
示例#3
0
def setup(dockerfile=None, image_tag_string=None):
    '''Any initial setup'''
    # generate random names for image, container, and tag
    general.initialize_names()
    # load the cache
    cache.load()
    # load dockerfile if present
    if dockerfile:
        dhelper.load_docker_commands(dockerfile)
    # check if the docker image is present
    if image_tag_string:
        if not container.check_image(image_tag_string):
            # if no docker image is present, try to pull it
            if not container.pull_image(image_tag_string):
                logger.fatal("%s", errors.cannot_find_image.format(
                    imagetag=image_tag_string))
                sys.exit()
示例#4
0
def setup(dockerfile=None, image_tag_string=None):
    '''Any initial setup'''
    # generate random names for image, container, and tag
    general.initialize_names()
    # load the cache
    cache.load()
    # load dockerfile if present
    if dockerfile:
        dhelper.load_docker_commands(dockerfile)
    # check if the docker image is present
    if image_tag_string:
        if not container.check_image(image_tag_string):
            # if no docker image is present, try to pull it
            if not container.pull_image(image_tag_string):
                logger.fatal(
                    errors.cannot_find_image.format(imagetag=image_tag_string))
                sys.exit()
    # create temporary working directory
    if not os.path.exists(constants.temp_folder):
        os.mkdir(constants.temp_folder)
    # set up folders for rootfs operations
    rootfs.set_up()