Esempio n. 1
0
def init_command(project_dir, assume_yes):
    """Initialize a new project.

    Returns:
        Exit code (0 on success)
    """
    # we don't want False right now because either you specify
    # --yes or we go with the default in project_ops.create
    # (depends on whether project file already exists).
    assert assume_yes is None or assume_yes is True

    if not os.path.exists(project_dir):
        if assume_yes:
            make_directory = True
        else:
            make_directory = console_ask_yes_or_no("Create directory '%s'?" %
                                                   project_dir,
                                                   default=False)
    else:
        make_directory = False

    project = project_ops.create(project_dir,
                                 make_directory=make_directory,
                                 fix_problems=assume_yes)
    if print_project_problems(project):
        return 1
    else:
        print("Project configuration is in %s" % project.project_file.filename)
        return 0
Esempio n. 2
0
def list_variables(project_dir):
    """List variables present in project."""
    project = load_project(project_dir)
    if console_utils.print_project_problems(project):
        return 1
    print("Variables for project: {}\n".format(project_dir))
    console_utils.print_names_and_descriptions(project.all_variable_requirements, name_attr='env_var')
    return 0
def list_env_specs(project_dir):
    """List environments in the project."""
    project = load_project(project_dir)
    if console_utils.print_project_problems(project):
        return 1
    print("Environments for project: {}\n".format(project_dir))
    console_utils.print_names_and_descriptions(project.env_specs.values())
    return 0
Esempio n. 4
0
def list_downloads(project_dir):
    """List the downloads present in project."""
    project = load_project(project_dir)
    if console_utils.print_project_problems(project):
        return 1

    if project.downloads:
        print("Downloads for project: {}\n".format(project_dir))
        console_utils.print_names_and_descriptions(
            project.download_requirements, name_attr='title')
    else:
        print("No downloads found in project.")
    return 0
Esempio n. 5
0
def list_services(project_dir):
    """List the services listed on the project."""
    project = load_project(project_dir)
    if console_utils.print_project_problems(project):
        return 1

    if project.services:
        print("Services for project: {}\n".format(project_dir))
        console_utils.print_names_and_descriptions(
            project.service_requirements, name_attr='title')
    else:
        print("No services found for project: {}".format(project_dir))
    return 0
def list_commands(project_dir):
    """List the commands on the project.

    Returns:
        int exit code
    """
    project = load_project(project_dir)
    if console_utils.print_project_problems(project):
        return 1

    if project.commands:
        print("Commands for project: {}\n".format(project_dir))
        console_utils.print_names_and_descriptions(project.commands.values())
    else:
        print("No commands found for project: {}\n".format(project_dir))
    return 0
def list_packages(project_dir, environment):
    """List the packages for an environment in the project."""
    project = load_project(project_dir)
    if console_utils.print_project_problems(project):
        return 1
    if environment is None:
        environment = project.default_env_spec_name
    env = project.env_specs.get(environment, None)
    if env is None:
        print("Project doesn't have an environment called '{}'".format(
            environment),
              file=sys.stderr)
        return 1
    print("Packages for environment '{}':\n".format(env.name))
    print("\n".join(sorted(env.conda_packages)), end='\n\n')
    return 0