'''
Created on Dec 26, 2012

__author__ = "Elizabeth 'pidge' Flanagan"
__copyright__ = "Copyright 2013, 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 twisted.python import log
from autobuilder.config import *

class GetDistroVersion(ShellCommand):
    haltOnFailure = False 
    flunkOnFailure = True 
    name = "GetDistroVersion" 
    def __init__(self, factory, argdict=None, **kwargs):
        for k, v in argdict.iteritems():
            setattr(self, k, v)
        self.description = "Get Distro Version"
        self.slaveworkdir=os.path.join(os.path.join(YOCTO_ABBASE, "yocto-slave"))
        # Timeout needs to be passed to LoggingBuildStep as a kwarg
        for k, v in argdict.iteritems():
            setattr(self, k, v)
        self.timeout = 100000
        kwargs['timeout']=self.timeout
        ShellCommand.__init__(self, **kwargs)

    def start(self):
        import os
        if "poky" in self.distro:
            pokyconf=self.slaveworkdir + "/" + buildername + "/build/conf/distro/poky.conf"
            distrofile = open(pokyconf, "r")
            for line in distrofile:
                if 'DISTRO_VERSION =' in line:
                    distroversion=line.replace("DISTRO_VERSION = ", "").replace("-${DATE}","").replace('"','')
            self.setProperty('distroversion', distroversion)
        ShellCommand.start(self)

    def describe(self, done=False):
        description = ShellCommand.describe(self,done)
        return description



'''
Created on Dec 26, 2012

__author__ = "Elizabeth 'pidge' Flanagan"
__copyright__ = "Copyright 2013, Intel Corp."
__credits__ = ["Elizabeth Flanagan"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = "Elizabeth Flanagan"
__email__ = "elizabeth.flanagan@intel.com"
'''
from buildbot.process.buildstep import BuildStep
from buildbot.status import progress
from buildbot.status.results import SUCCESS, WARNINGS, FAILURE, SKIPPED, \
     EXCEPTION, RETRY, worst_status
from twisted.python import log
from autobuilder.config import *

class GetDistroVersion(BuildStep):
    haltOnFailure = False 
    flunkOnFailure = True 
    name = "GetDistroVersion" 
    def __init__(self, factory, argdict=None, **kwargs):
        for k, v in argdict.iteritems():
            setattr(self, k, v)
        self.description = "Get Distro Version"
        self.slaveworkdir=os.path.join(os.path.join(YOCTO_ABBASE, "yocto-slave"))
        # Timeout needs to be passed to LoggingBuildStep as a kwarg
        for k, v in argdict.iteritems():
            setattr(self, k, v)
        self.timeout = 100000
        kwargs['timeout']=self.timeout
        self._pendingLogObservers = []
        self._acquiringLock = None
        self.stopped = False

    def start(self):
        import os
        buildername=self.getProperty("buildername")
        if "poky" in self.distro:
            pokyconf=self.slaveworkdir + "/" + buildername + "/build/meta-yocto/conf/distro/poky.conf"
            distrofile = open(pokyconf, "r")
            for line in distrofile:
                if 'DISTRO_VERSION =' in line:
                    distroversion=line.replace("DISTRO_VERSION = ", "").replace("-${DATE}","").replace('"','')
            self.setProperty('distroversion', distroversion)
        self.finished(SUCCESS)



Switch from ShellCommand to BuildStep