aboutsummaryrefslogtreecommitdiffstats
path: root/lib/python2.7/site-packages/buildbot-0.8.8-py2.7.egg/buildbot/steps/package/deb/lintian.py
blob: 5c01a15dcd0d139f8d1bf31c2d9a82772b5eddae (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
80
81
82
83
84
85
86
87
88
89
90
91
# This program is free software; you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Portions Copyright Buildbot Team Members
# Portions Copyright Marius Rieder <marius.rieder@durchmesser.ch>
"""
Steps and objects related to lintian
"""

from buildbot.steps.shell import ShellCommand
from buildbot.status.results import SUCCESS, WARNINGS, FAILURE
from buildbot import config

class DebLintian(ShellCommand):
    name = "lintian"
    description = ["Lintian running"]
    descriptionDone = ["Lintian"]

    fileloc = None
    suppressTags = []

    warnCount = 0
    errCount = 0

    flunkOnFailure=False
    warnOnFailure=True

    def __init__(self, fileloc=None, suppressTags=None, **kwargs):
        """
        Create the DebLintian object.
        
        @type fileloc: str
        @param fileloc: Location of the .deb or .changes to test.
        @type suppressTags: list
        @param suppressTags: List of tags to suppress.
        @type kwargs: dict
        @param kwargs: all other keyword arguments.
        """
        ShellCommand.__init__(self, **kwargs)
        if fileloc:
            self.fileloc = fileloc
        if suppressTags:
            self.suppressTags = suppressTags

        if not self.fileloc:
            config.error("You must specify a fileloc")

        self.command = ["lintian", "-v", self.fileloc]

        if self.suppressTags:
            for tag in self.suppressTags:
                self.command += ['--suppress-tags', tag]

    def createSummary(self, log):
        """
        Create nice summary logs.
        
        @param log: log to create summary off of.
        """
        warnings = []
        errors = []
        for line in log.readlines():
            if 'W: ' in line:
                warnings.append(line)
            elif 'E: ' in line:
                errors.append(line)

        if warnings:
            self.addCompleteLog('%d Warnings' % len(warnings), "".join(warnings))
            self.warnCount = len(warnings)
        if errors:
            self.addCompleteLog('%d Errors' % len(errors), "".join(errors))
            self.errCount = len(errors)

    def evaluateCommand(self, cmd):
        if ( cmd.rc != 0 or self.errCount):
            return FAILURE
        if self.warnCount:
            return WARNINGS
        return SUCCESS