Changeset 6dc551c in rtems-source-builder for source-builder/sb/ereport.py


Ignore:
Timestamp:
Oct 12, 2017, 2:40:12 AM (2 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
master
Children:
7b68249
Parents:
c4b6bf0
git-author:
Chris Johns <chrisj@…> (10/12/17 02:40:12)
git-committer:
Chris Johns <chrisj@…> (10/12/17 02:48:52)
Message:

sb: Move the option check for reporting errors to the error reporter.

Updates #2536.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source-builder/sb/ereport.py

    rc4b6bf0 r6dc551c  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2017 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    2222#
    2323
     24from __future__ import print_function
     25
    2426import os
    2527
     
    2830
    2931def generate(name, opts, header = None, footer = None):
    30     r = ['RTEMS Tools Project - Source Builder Error Report'] + []
    31     if header:
    32         r += [' %s' % (header)]
    33     r += [opts.info()]
    34     if opts.defaults.get_value('%{_sbgit_valid}') == '1':
    35         r += [' %s/%s' % (opts.defaults.get_value('%{_sbgit_remotes}'),
    36                           opts.defaults.get_value('%{_sbgit_id}'))]
    37     else:
    38         r += [' RSB: not a valid repo']
    39     if os.name == 'nt':
    40         r += [' Windows']
    41     else:
    42         r += [' %s' % (' '.join(os.uname()))]
    43     r += []
    44     r += ['Tail of the build log:']
    45     r += log.tail()
    46     if footer:
    47         r += [footer]
    48     try:
    49         name = name.replace('/', '-')
    50         l = open(name, 'w')
    51         l.write(os.linesep.join(r))
    52         l.close()
    53         log.notice('  See error report: %s' % (name))
    54     except:
    55         log.stderr('error: failure to create error report')
    56         raise
     32    label, result = opts.with_arg('error-report')
     33    if (label.startswith('without_') and result != 'yes') or \
     34       (label.startswith('with_') and result != 'no'):
     35        r = ['RTEMS Tools Project - Source Builder Error Report'] + []
     36        if header:
     37            r += [' %s' % (header)]
     38        r += [opts.info()]
     39        if opts.defaults.get_value('%{_sbgit_valid}') == '1':
     40            r += [' %s/%s' % (opts.defaults.get_value('%{_sbgit_remotes}'),
     41                              opts.defaults.get_value('%{_sbgit_id}'))]
     42        else:
     43            r += [' RSB: not a valid repo']
     44        if os.name == 'nt':
     45            r += [' Windows']
     46        else:
     47            r += [' %s' % (' '.join(os.uname()))]
     48        r += []
     49        r += ['Tail of the build log:']
     50        r += log.tail()
     51        if footer:
     52            r += [footer]
     53        try:
     54            name = name.replace('/', '-')
     55            with open(name, 'w') as l:
     56                l.write(os.linesep.join(r))
     57            log.notice('  See error report: %s' % (name))
     58        except:
     59            log.stderr('error: failure to create error report')
     60            raise
Note: See TracChangeset for help on using the changeset viewer.