source: rtems-source-builder/source-builder/sb/ereport.py @ 6dc551c

Last change on this file since 6dc551c was 6dc551c, checked in by Chris Johns <chrisj@…>, on Oct 12, 2017 at 2:40:12 AM

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

Updates #2536.

  • Property mode set to 100755
File size: 2.2 KB
Line 
1#
2# RTEMS Tools Project (http://www.rtems.org/)
3# Copyright 2010-2017 Chris Johns (chrisj@rtems.org)
4# All rights reserved.
5#
6# This file is part of the RTEMS Tools package in 'rtems-testing'.
7#
8# Permission to use, copy, modify, and/or distribute this software for any
9# purpose with or without fee is hereby granted, provided that the above
10# copyright notice and this permission notice appear in all copies.
11#
12# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20#
21# Create an error log.
22#
23
24from __future__ import print_function
25
26import os
27
28import error
29import log
30
31def generate(name, opts, header = None, footer = None):
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 TracBrowser for help on using the repository browser.