aboutsummaryrefslogtreecommitdiffstats
path: root/lib/python2.7/site-packages/autobuilder/Yocto_Message_Formatter.py
blob: 611da1f8eb754d8a8620ff52a44e43701d6905e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
'''
Created on Jun 3, 2013

__author__ = "Elizabeth 'pidge' Flanagan"
__copyright__ = "Copyright 2013, Intel Corp."
__credits__ = ["Elizabeth Flanagan"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = "Elizabeth Flanagan"
__email__ = "pidge@toganlabs.com"
'''
#!/usr/bin/python
from twisted.python import log
from buildbot.status.builder import Results

def message_formatter(mode, name, build, results, master_status):
    result = Results[results]
    limit_lines = 60
    text = list()
    text.append('<h4>Build status: %s</h4>' % result.upper())
    text.append("Build worker for this Build: <b>%s</b>" % build.getSlavename())
    text.append('<br>')
    if master_status.getURLForThing(build):
        text.append('Complete logs for all build steps: <a href="%s">%s</a>'
                 % (master_status.getURLForThing(build),
                    master_status.getURLForThing(build))
                 )
    text.append('<br>')
    text.append("Build Reason: %s" % build.getReason())
    text.append('<br>')

    try:
        build_properties = build.getProperties().asList()
    except:
        pass
    if build_properties:
        text.append("Build Properties:<br>")
        text.append("<ul>")
        for prop in build_properties:
            if str(prop[1]) != '':
                if prop[0] == "BBLAYERS" or prop[0] == "LOCALCONF":
                    if prop[0] == 'BBLAYERS':
                        text.append('<li>Contents of bblayers.conf (Note. LCONF_VERSION will not show up correctly)<br><code>')
                    else:
                        text.append('<li>Contents of auto.conf (local.conf for autobuilders)<br><code>')
                    lines=prop[1].splitlines()
                    for line in lines:
                        text.append(line + "<br>")
                    text.append('<br></code></li>')
                elif "trigger" not in prop[0] and "ss_" not in prop[0]:
                    text.append('<li>' + prop[0] + " : " + str(prop[1])+"</li>")
        text.append('</ul>')
    url = ""
    for log in build.getLogs():
         log_name = "%s.%s" % (log.getStep().getName(), log.getName())
         log_status, dummy = log.getStep().getResults()
         log_body = []
         for line in log.getText().splitlines(): # Note: can be VERY LARGE
            print line
            if "ERROR" in line or "|" in line:
               log_body.append(line)

         log_url = '%s/steps/%s/logs/%s' % (master_status.getURLForThing(build),
                                            log.getStep().getName(),
                                            log.getName())

         if log_status == 2 and log_body:
            text.append('<i>Detailed log of last build step:</i> <a href="%s">%s</a>'
                        % (log_url, log_url))
            text.append('<br>')
            text.append('<h4>Last %d lines of "%s" Error log:</h4>' % (limit_lines, log_name))
            text.append('<p>')
            text.append('<br>'.join([line for line in
                                     log_body[len(log_body)-limit_lines:]]))
            text.append('</p>')
    text.append('<br><br>')
    text.append('<b>-The Yocto BuildBot</b>')
    return {'body': "\n".join(text), 'type': 'html'}