Exemple #1
0
def project_link(valid_token=None, puts_result=True, auto_link=True):

    if not valid_token:
        raise ValueError("A valid token is required!")

    term = get_term()

    if puts_result:
        puts("Searching for git remote information... ")

    path = find_git_root(os.curdir)

    if not path:
        if puts_result:
            puts(term.red("error:") + " No git repository found")
        return False

    options = get_remote_options(path)

    if options is None:
        if puts_result:
            puts(term.red("error:") + " No git repository found")
        return False

    if puts_result:
        puts("Retrieving list of applications...")

    c = Client()

    response, result = c.get_applications(valid_token)

    for option in options:
        for app in result:

            if convert_to_url(app['url']) == convert_to_url(option.url):

                if auto_link:
                    set_value(VALUE_PROJECT_ID, app['id'])

                if puts_result:
                    puts(
                        term.green("success:") +
                        " application is now linked to this repository"
                    )
                return True

    if puts_result:
        puts(
            "An application could " + term.white("not") +
            " be linked to this repository")
    return False
Exemple #2
0
def project_link(valid_token=None, puts_result=True, auto_link=True):

    if not valid_token:
        raise ValueError("A valid token is required!")

    term = get_term()

    if puts_result:
        puts("Searching for git remote information... ")

    path = find_git_root(os.curdir)

    if not path:
        if puts_result:
            puts(term.red("error:") + " No git repository found")
        return False

    options = get_remote_options(path)

    if options is None:
        if puts_result:
            puts(term.red("error:") + " No git repository found")
        return False

    if puts_result:
        puts("Retrieving list of applications...")

    c = Client()

    response, result = c.get_applications(valid_token)

    for option in options:
        for app in result:

            if convert_to_url(app['url']) == convert_to_url(option.url):

                if auto_link:
                    set_value(VALUE_PROJECT_ID, app['id'])

                if puts_result:
                    puts(
                        term.green("success:") +
                        " application is now linked to this repository"
                    )
                return True

    if puts_result:
        puts(
            "An application could " + term.white("not") +
            " be linked to this repository")
    return False
Exemple #3
0
def project_list(valid_token=None):

    if not valid_token:
        raise ValueError("A valid token is required!")

    c = Client()

    response, result = c.get_applications(valid_token)

    header = ['name', 'author', 'status', 'followers', 'url']
    props = [
        'name',
        'author',
        'status',
        'totalFollowers',
        'url'
    ]

    max_lengths = []

    for i in range(len(header)):
        max_lengths.append(0)

    store_highest_length(max_lengths, header)

    puts("Found %d result(s)...\n" % len(result))
    for row in result:
        store_highest_length(max_lengths, row, props)

    result = sorted(result, key=lambda k: k['name'])
    print_hr(max_lengths, first=True)
    print_line(max_lengths, header)
    print_hr(max_lengths)

    for row in result:
        print_line(max_lengths, row, props)
    print_hr(max_lengths)
Exemple #4
0
def project_list(valid_token=None):

    if not valid_token:
        raise ValueError("A valid token is required!")

    c = Client()

    response, result = c.get_applications(valid_token)

    header = ['name', 'author', 'status', 'followers', 'url']
    props = [
        'name',
        'author',
        'status',
        'totalFollowers',
        'url'
    ]

    max_lengths = []

    for i in range(len(header)):
        max_lengths.append(0)

    store_highest_length(max_lengths, header)

    puts("Found %d result(s)...\n" % len(result))
    for row in result:
        store_highest_length(max_lengths, row, props)

    result = sorted(result, key=lambda k: k['name'])
    print_hr(max_lengths, first=True)
    print_line(max_lengths, header)
    print_hr(max_lengths)

    for row in result:
        print_line(max_lengths, row, props)
    print_hr(max_lengths)