Example #1
0
def _print_path(name, extra=None):
    if name == 'aeriscloud':
        print(aeriscloud_path)
    elif name == 'projects_path':
        print(projects_path())
    elif name == 'data_dir':
        print(data_dir())
    elif name == 'config_dir':
        print(config_dir())
    elif name == 'organization':
        print(get_env_path(extra))
Example #2
0
def cli(up, make, box_name, folder):
    """
    Initialize a new AerisCloud project
    """
    if not folder:
        folderpath = os.getcwd()
    else:
        folderpath = os.path.join(os.curdir, folder)
        relpath = os.path.relpath(folderpath, projects_path())
        if relpath[:2] == '..':
            warning("""You are trying to create a new project in %s
which is outside of your projects' directory (%s).""" %
                    (os.path.abspath(folderpath), projects_path()))
            folder_in_projectpath = os.path.join(projects_path(), folder)
            if click.confirm("Do you want to create it in %s instead?" %
                             folder_in_projectpath, default=True):
                folderpath = folder_in_projectpath

    if not os.path.exists(folderpath):
        os.makedirs(folderpath)

    os.chdir(folderpath)

    git_root = _get_git_root()
    project = Project(git_root)

    _ask_project_details(git_root, project)

    click.echo('\nWriting .aeriscloud.yml ... ', nl=False)
    project.save()
    click.echo('done')

    move_shell_to(project.folder())

    if up or make:
        # Retrieve the proper box
        box = project.box(box_name)

        _up(box, make)
Example #3
0
def _print_projects():
    """
    Print the list of projects (uses the folder names)
    """
    project_dir = projects_path()
    print(' '.join(
        ['aeriscloud'] +
        [
            pro
            for pro in os.listdir(project_dir)
            if os.path.exists(os.path.join(project_dir, pro,
                                           '.aeriscloud.yml'))
        ]
    ))
Example #4
0
def cli(project):
    """
    Goto a project's directory
    """
    if not project:
        move_shell_to(projects_path())
        return

    pro = get(project)

    if not pro:
        click.secho('error: project %s does not exists' % project,
                    fg='red', err=True)
        sys.exit(errno.ENOENT)

    move_shell_to(pro.folder())
Example #5
0
def _clone_project(project_name):
    gh = Github()

    (gh_repo, forked) = gh.get_repo(project_name, fork=True)
    if not gh_repo:
        click.echo('error: no repository named %s was found on '
                   'your user and configured organizations' %
                   click.style(project_name, bold=True))
        sys.exit(1)

    if forked:
        click.echo('We found a repository named %s and forked it to your '
                   'user, it now accessible at the following url:\n'
                   '%s' % (forked.full_name, gh_repo.html_url))

    dest_path = os.path.join(projects_path(), project_name)
    click.echo('We will clone %s in %s\n' % (gh_repo.ssh_url, dest_path))

    vgit('clone', gh_repo.ssh_url, dest_path)

    # add our upstream remote
    if gh_repo.parent:
        repo = Repo(dest_path)
        repo.create_remote('upstream', gh_repo.parent.ssh_url)