コード例 #1
0
ファイル: show.py プロジェクト: hdrodz97/Cook
def tabulate_job_instances(instances):
    """Returns a table displaying the instance info"""
    if len(instances) > 0:
        rows = [
            collections.OrderedDict([('Job Instance', i['task_id']),
                                     ('Run Time', format_instance_run_time(i)),
                                     ('Host', i['hostname']),
                                     ('Instance Status',
                                      format_instance_status(i))])
            for i in instances
        ]
        instance_table = tabulate(rows, headers='keys', tablefmt='plain')
        return '\n\n%s' % instance_table
    else:
        return ''
コード例 #2
0
ファイル: show.py プロジェクト: hdrodz97/Cook
def tabulate_instance(cluster_name, instance_job_pair):
    """Given an instance, returns a string containing a table for the instance fields"""
    instance = instance_job_pair[0]
    job = instance_job_pair[1]

    left = [['Cluster', cluster_name], ['Host', instance['hostname']],
            ['Agent', instance['slave_id']],
            ['Job', '%s (%s)' % (job['name'], job['uuid'])]]
    if len(instance['ports']) > 0:
        left.append(['Ports Allocated', format_list(instance['ports'])])

    right = [['Run Time', format_instance_run_time(instance)],
             ['Instance Status',
              format_instance_status(instance)],
             ['Job Status', format_job_status(job)]]
    if 'exit_code' in instance:
        right.append(['Exit Code', instance['exit_code']])

    left_table = tabulate(left, tablefmt='plain')
    right_table = tabulate(right, tablefmt='plain')
    instance_tables = juxtapose_text(left_table, right_table)
    return '\n=== Job Instance: %s ===\n\n%s' % (instance['task_id'],
                                                 instance_tables)