Example #1
0
    def process_run_result(self, result, context):
        counter = Counter()
        for ir in result.iteration_results:
            counter[ir.status] += 1

        outfile = os.path.join(context.run_output_directory, 'status.txt')
        self.logger.info('Status available in {}'.format(outfile))
        with open(outfile, 'w') as wfh:
            wfh.write('Run name: {}\n'.format(context.run_info.run_name))
            wfh.write('Run status: {}\n'.format(context.run_result.status))
            wfh.write('Date: {}\n'.format(time.strftime("%c")))
            wfh.write('{}/{} iterations completed without error\n'.format(counter['OK'], len(result.iteration_results)))
            wfh.write('\n')
            status_lines = [map(str, [ir.id, ir.spec.label, ir.iteration, ir.status,
                                      ir.events and ir.events[0].message.split('\n')[0] or ''])
                            for ir in result.iteration_results]
            write_table(status_lines, wfh, align='<<>><')
        context.add_artifact('run_status_summary', 'status.txt', 'export')
Example #2
0
    def process_run_result(self, result, context):
        counter = Counter()
        for ir in result.iteration_results:
            counter[ir.status] += 1

        outfile = os.path.join(context.run_output_directory, 'status.txt')
        self.logger.info('Status available in {}'.format(outfile))
        with open(outfile, 'w') as wfh:
            wfh.write('Run name: {}\n'.format(context.run_info.run_name))
            wfh.write('Run status: {}\n'.format(context.run_result.status))
            wfh.write('Date: {}\n'.format(time.strftime("%c")))
            wfh.write('{}/{} iterations completed without error\n'.format(counter['OK'], len(result.iteration_results)))
            wfh.write('\n')
            status_lines = [map(str, [ir.id, ir.spec.label, ir.iteration, ir.status,
                                      ir.events and ir.events[0].message.split('\n')[0] or ''])
                            for ir in result.iteration_results]
            write_table(status_lines, wfh, align='<<>><')
        context.add_artifact('run_status_summary', 'status.txt', 'export')
def _diff_interrupt_files(before, after, result):  # pylint: disable=R0914
    output_lines = []
    with open(before) as bfh:
        with open(after) as ofh:
            for bline, aline in izip(bfh, ofh):
                bchunks = bline.strip().split()
                while True:
                    achunks = aline.strip().split()
                    if achunks[0] == bchunks[0]:
                        diffchunks = ['']
                        diffchunks.append(achunks[0])
                        diffchunks.extend([
                            diff_tokens(b, a)
                            for b, a in zip(bchunks[1:], achunks[1:])
                        ])
                        output_lines.append(diffchunks)
                        break
                    else:  # new category appeared in the after file
                        diffchunks = ['>'] + achunks
                        output_lines.append(diffchunks)
                        try:
                            aline = ofh.next()
                        except StopIteration:
                            break

    # Offset heading columns by one to allow for row labels on subsequent
    # lines.
    output_lines[0].insert(0, '')

    # Any "columns" that do not have headings in the first row are not actually
    # columns -- they are a single column where space-spearated words got
    # split. Merge them back together to prevent them from being
    # column-aligned by write_table.
    table_rows = [output_lines[0]]
    num_cols = len(output_lines[0])
    for row in output_lines[1:]:
        table_row = row[:num_cols]
        table_row.append(' '.join(row[num_cols:]))
        table_rows.append(table_row)

    with open(result, 'w') as wfh:
        write_table(table_rows, wfh)
Example #4
0
def _diff_interrupt_files(before, after, result):  # pylint: disable=R0914
    output_lines = []
    with open(before) as bfh:
        with open(after) as ofh:
            for bline, aline in izip(bfh, ofh):
                bchunks = bline.strip().split()
                while True:
                    achunks = aline.strip().split()
                    if achunks[0] == bchunks[0]:
                        diffchunks = ['']
                        diffchunks.append(achunks[0])
                        diffchunks.extend([diff_tokens(b, a) for b, a
                                           in zip(bchunks[1:], achunks[1:])])
                        output_lines.append(diffchunks)
                        break
                    else:  # new category appeared in the after file
                        diffchunks = ['>'] + achunks
                        output_lines.append(diffchunks)
                        try:
                            aline = ofh.next()
                        except StopIteration:
                            break

    # Offset heading columns by one to allow for row labels on subsequent
    # lines.
    output_lines[0].insert(0, '')

    # Any "columns" that do not have headings in the first row are not actually
    # columns -- they are a single column where space-spearated words got
    # split. Merge them back together to prevent them from being
    # column-aligned by write_table.
    table_rows = [output_lines[0]]
    num_cols = len(output_lines[0])
    for row in output_lines[1:]:
        table_row = row[:num_cols]
        table_row.append(' '.join(row[num_cols:]))
        table_rows.append(table_row)

    with open(result, 'w') as wfh:
        write_table(table_rows, wfh)