'''
Created on June 17th, 2015

__author__ = "Elizabeth 'pidge' Flanagan"
__copyright__ = "Copyright 2012-2015, Intel Corp."
__credits__ = ["Elizabeth Flanagan"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = "Elizabeth Flanagan"
__email__ = "elizabeth.flanagan@intel.com"
'''

from buildbot.steps.shell import ShellCommand
from buildbot.process.buildstep import LogLineObserver
from buildbot.status.results import SUCCESS, FAILURE, WARNINGS

class CheckForGPLv3(ShellCommand):
    haltOnFailure = False
    flunkOnFailure = True
    name = "CheckForGPLv3"
    def __init__(self, factory, argdict=None, **kwargs):
        self.factory = factory
        for k, v in argdict.iteritems():
            setattr(self, k, v)
        # Timeout needs to be passed to LoggingBuildStep as a kwarg
        self.timeout = 100000
        kwargs['timeout']=self.timeout
        ShellCommand.__init__(self, **kwargs)

    def start(self):
        self.command = 'for x in `find build/tmp/deploy/license -name "license.manifest"`; do cat $x|grep GPLv3; done'
        self.description = ["Checking to ensure no GPLv3 packages"]
        ShellCommand.start(self)

    def commandComplete(self, cmd):
        result = cmd.logs['stdio'].getText()
        hasGPLv3 = ""
        try:
            hasGPLv3 = result.split()[-1]:
        except:
            self.setProperty('hasGPLv3', "False", "No GPLv3, we're ok.")
            self.finished(SUCCESS)
        if "|" in result:
            self.setProperty('hasGPLv3', "True", "A license may be dual licensed as GPLv3")
            self.finished(WARNINGS)
        else:
            self.setProperty('hasGPLv3', "True", "GPLv3, Fail out.")
            self.finished(FAILURE)

    def getText(self, cmd, results):
        return ShellCommand.getText(self, cmd, results)

'''
Created on June 17th, 2015

__author__ = "Elizabeth 'pidge' Flanagan"
__copyright__ = "Copyright 2012-2015, Intel Corp."
__credits__ = ["Elizabeth Flanagan"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = "Elizabeth Flanagan"
__email__ = "elizabeth.flanagan@intel.com"
'''

from buildbot.steps.shell import ShellCommand
from buildbot.process.buildstep import LogLineObserver
from buildbot.status.results import SUCCESS, FAILURE, WARNINGS

class CheckForGPLv3(ShellCommand):
    haltOnFailure = False
    flunkOnFailure = True
    name = "CheckForGPLv3"
    def __init__(self, factory, argdict=None, **kwargs):
        self.factory = factory
        for k, v in argdict.iteritems():
            setattr(self, k, v)
        # Timeout needs to be passed to LoggingBuildStep as a kwarg
        self.timeout = 100000
        kwargs['timeout']=self.timeout
        ShellCommand.__init__(self, **kwargs)

    def start(self):
        self.command = 'for x in `find ./build/tmp/deploy/licenses -name "license.manifest"`; do cat $x|grep GPLv3; done'
        self.description = ["Checking to ensure no GPLv3 packages"]
        ShellCommand.start(self)

    def commandComplete(self, cmd):
        result = cmd.logs['stdio'].getText()
        hasGPLv3 = ""
        try:
            hasGPLv3 = result.split()[-1]
        except:
            self.setProperty('hasGPLv3', "False", "No GPLv3, we're ok.")
            self.finished(SUCCESS)
        if "|" in result:
            self.setProperty('hasGPLv3', "True", "A license may be dual licensed as GPLv3")
            self.description = ["A license may be dual licensed as GPLv3"]
            self.finished(SUCCESS)
        else:
            self.setProperty('hasGPLv3', "True", "GPLv3, Fail out.")
            self.finished(FAILURE)


Switch from WARNING to SUCCESS