Exemplo n.º 1
0
def print_deploys(deploys, print_index=False):

    for data in deploys:
        if 'creationDate' in data:
            data['creationDate'] = \
                format_date(data['creationDate'])

        if "progress" in data:
            data['progress'] = "{progress:.1f}%".format(
                progress=data['progress'])

        if "user" in data:
            data["user_name"] = data["user"]["name"]
            data["user_type"] = data["user"]["type"]

    header = [
        'result',
        'progress',
        'deploy by',
        'created',
    ]

    props = [
        'result',
        'progress',
        'user_name',
        'creationDate',
    ]

    if print_index:
        header = [''] + header
        props = ['index'] + props

    max_lengths = []

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

    store_highest_length(max_lengths, header)

    index = 0

    for row in deploys:
        if print_index:
            row['index'] = index + 1
        index += 1
        store_highest_length(max_lengths, row, props)

    print_hr(max_lengths, first=True)
    print_line(max_lengths, header)
    print_hr(max_lengths)

    for row in deploys:
        print_line(max_lengths, row, props)
    print_hr(max_lengths)
Exemplo n.º 2
0
def print_deploys(deploys, print_index=False):

    for data in deploys:
        if 'creationDate' in data:
            data['creationDate'] = \
                format_date(data['creationDate'])

        if "progress" in data:
            data['progress'] = "{progress:.1f}%".format(
                progress=data['progress'])

        if "user" in data:
            data["user_name"] = data["user"]["name"]
            data["user_type"] = data["user"]["type"]

    header = [
        'result',
        'progress',
        'deploy by',
        'created',
    ]

    props = [
        'result',
        'progress',
        'user_name',
        'creationDate',
    ]

    if print_index:
        header = [''] + header
        props = ['index'] + props

    max_lengths = []

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

    store_highest_length(max_lengths, header)

    index = 0

    for row in deploys:
        if print_index:
            row['index'] = index + 1
        index += 1
        store_highest_length(max_lengths, row, props)

    print_hr(max_lengths, first=True)
    print_line(max_lengths, header)
    print_hr(max_lengths)

    for row in deploys:
        print_line(max_lengths, row, props)
    print_hr(max_lengths)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 5
0
def print_builds(builds, print_index=False, limit=5):

    result = builds

    header = [
        'result',
        'progress',
        'branch',
        'hash',
        'created',
        'message',
    ]

    props = [
        'result',
        'progress',
        'branch',
        # 'deployResult',
        # 'deployBy',
        # 'deployFinishedOn',
        # 'branch',
        'commit',
        'creationDate',
        # 'deployStatus',
        'commitMessage',
    ]

    if print_index:
        header = [''] + header
        props = ['index'] + props

    max_lengths = []

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

    store_highest_length(max_lengths, header)

    if type(result) is list:
        index = 0
        result = result[:limit]
        if type(result) is list:
            puts("Found %d result(s)...\n" % len(result))

        for row in result:
            if "startedOn" in row:
                row['creationDate'] = format_date(row['creationDate'])

            if "progress" in row:
                row['progress'] = "{progress:.1f}%".format(
                    progress=row['progress'])

            if "commit" in row:
                row["commit"] = row['commit'][:8]

            if print_index:
                row['index'] = index + 1

            store_highest_length(max_lengths, row, props)

            index += 1

        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)

        if len(result) == 0:
            print_hr(max_lengths)
Exemplo n.º 6
0
def print_builds(builds, print_index=False, limit=5):

    result = builds

    header = [
        'result',
        'progress',
        'branch',
        'hash',
        'created',
        'message',
    ]

    props = [
        'result',
        'progress',
        'branch',
        # 'deployResult',
        # 'deployBy',
        # 'deployFinishedOn',
        # 'branch',
        'commit',
        'creationDate',
        # 'deployStatus',
        'commitMessage',
    ]

    if print_index:
        header = [''] + header
        props = ['index'] + props

    max_lengths = []

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

    store_highest_length(max_lengths, header)

    if type(result) is list:
        index = 0
        result = result[:limit]
        if type(result) is list:
            puts("Found %d result(s)...\n" % len(result))

        for row in result:
            if "startedOn" in row:
                row['creationDate'] = format_date(row['creationDate'])

            if "progress" in row:
                row['progress'] = "{progress:.1f}%".format(
                    progress=row['progress'])

            if "commit" in row:
                row["commit"] = row['commit'][:8]

            if print_index:
                row['index'] = index + 1

            store_highest_length(max_lengths, row, props)

            index += 1

        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)

        if len(result) == 0:
            print_hr(max_lengths)
Exemplo n.º 7
0
def print_targets(targets, print_index=False):

    result = targets

    if 'data' in result:
        for data in result['data']:
            if 'deployFinishedOn' in data:
                data['deployFinishedOn'] = \
                    format_date(data['deployFinishedOn'])

            if 'commitHash' in data:
                data['commitHash'] = data['commitHash'][:8]

    header = [
        'target',
        'result',
        'deploy by',
        'deployed on',
        'branch',
        'commit',
        # 'status',
        'message'
    ]

    props = [
        'name',
        'deployResult',
        'deployBy',
        'deployFinishedOn',
        'branch',
        'commitHash',
        # 'deployStatus',
        'commitMessage',
    ]

    if print_index:
        header = [''] + header
        props = ['index'] + props

    max_lengths = []

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

    store_highest_length(max_lengths, header)

    if 'data' in result:
        puts("Found %d result(s)...\n" % len(result['data']))
        index = 0
        for row in result['data']:
            if print_index:
                row['index'] = index + 1
            index += 1
            store_highest_length(max_lengths, row, props)

        print_hr(max_lengths, first=True)
        print_line(max_lengths, header)
        print_hr(max_lengths)

        for row in result['data']:
            print_line(max_lengths, row, props)
        print_hr(max_lengths)
Exemplo n.º 8
0
def print_targets(targets, print_index=False):

    result = targets

    if 'data' in result:
        for data in result['data']:
            if 'deployFinishedOn' in data:
                data['deployFinishedOn'] = \
                    format_date(data['deployFinishedOn'])

            if 'commitHash' in data:
                data['commitHash'] = data['commitHash'][:8]

    header = [
        'target',
        'result',
        'deploy by',
        'deployed on',
        'branch',
        'commit',
        # 'status',
        'message'
    ]

    props = [
        'name',
        'deployResult',
        'deployBy',
        'deployFinishedOn',
        'branch',
        'commitHash',
        # 'deployStatus',
        'commitMessage',
    ]

    if print_index:
        header = [''] + header
        props = ['index'] + props

    max_lengths = []

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

    store_highest_length(max_lengths, header)

    if 'data' in result:
        puts("Found %d result(s)...\n" % len(result['data']))
        index = 0
        for row in result['data']:
            if print_index:
                row['index'] = index + 1
            index += 1
            store_highest_length(max_lengths, row, props)

        print_hr(max_lengths, first=True)
        print_line(max_lengths, header)
        print_hr(max_lengths)

        for row in result['data']:
            print_line(max_lengths, row, props)
        print_hr(max_lengths)