예제 #1
0
def init():
    """
    Initialize a new python project with default files.  Default values from herring.conf and directory name.
    """
    defaults = _project_defaults()

    if Project.prompt:
        defaults['name'] = prompt("Enter the project's name:", defaults['name'])
        defaults['package'] = prompt("Enter the project's package:", defaults['package'])
        defaults['author'] = prompt("Enter the project's author:", defaults['author'])
        defaults['author_email'] = prompt("Enter the project's author's email:", defaults['author_email'])
        defaults['description'] = prompt("Enter the project's description:", defaults['description'])

    # print("defaults:\n{defaults}".format(defaults=pformat(defaults)))

    if Project.use_templates:

        template = Template()

        for template_dir in [os.path.abspath(os.path.join(herringlib, 'herringlib', 'templates'))
                             for herringlib in HerringFile.herringlib_paths]:

            info("template directory: %s" % template_dir)
            # noinspection PyArgumentEqualDefault
            template.generate(template_dir, defaults, overwrite=False)
예제 #2
0
    def new_image():
        """Create a new image directory and populate with a default Dockerfile."""
        names = list(task.argv)
        if not names:
            if Project.prompt and task.arg_prompt is not None:
                name = prompt(task.arg_prompt)
                if name is not None and name.strip():
                    names.append(name)

        for name in names:
            container_dir = os.path.join(Project.docker_dir, Project.docker_containers_dir, name)
            mkdir_p(container_dir)
            # populate container dir with Dockerfile and .dockerignore
            dockerfile = os.path.join(container_dir, 'Dockerfile')
            dockerignore = os.path.join(container_dir, '.dockerignore')
            shutil.copyfile(DOCKERFILE_TEMPLATE, dockerfile)
            touch(dockerignore)
            info("Created folder for new image at: {dir}".format(dir=container_dir))