from buildbot.process import buildstep
from buildbot.process.buildstep import SUCCESS, FAILURE, EXCEPTION
from buildbot.process.properties import Properties
from twisted.internet import defer

from ..travisyml import TravisYml


class ConfigurableStep(buildstep.LoggingBuildStep):

    """
    Base class for a step which can be tuned by changing settings in .travis.yml
    """

    @defer.inlineCallbacks
    def getStepConfig(self):
        config = TravisYml()

        struct = self.build.getProperty(".travis.yml", None)
        if struct:
            config.parse(struct)
            defer.returnValue(config)
             
        log = self.addLog(".travis.yml")
        cmd = self.cmd = buildstep.RemoteShellCommand(workdir="build", command=["cat", ".travis.yml"])
        cmd.useLog(log, False, "stdio")
        yield self.runCommand(cmd)
        self.cmd = None
        if cmd.rc != 0:
            raise buildstep.BuildStepFailed()

        config = TravisYml()
        config.parse(log.getText())

        self.build.setProperty(".travis.yml", config.config, ".VCS")

        defer.returnValue(config)


from buildbot.process import buildstep
from buildbot.process.buildstep import SUCCESS, FAILURE, EXCEPTION
from buildbot.process.properties import Properties
from twisted.internet import defer

from ..travisyml import TravisYml


class ConfigurableStep(buildstep.LoggingBuildStep):

    """
    Base class for a step which can be tuned by changing settings in .travis.yml
    """

    @defer.inlineCallbacks
    def getStepConfig(self):
        log = self.addLog(".travis.yml")
        cmd = self.cmd = buildstep.RemoteShellCommand(workdir="build", command=["cat", ".travis.yml"])
        cmd.useLog(log, False, "stdio")
        yield self.runCommand(cmd)
        self.cmd = None
        if cmd.rc != 0:
            raise buildstep.BuildStepFailed()

        config = TravisYml()
        config.parse(log.getText())

        defer.returnValue(config)


Revert "Save .travis.yml into build properties"
Revert "Save .travis.yml into build properties"

The data is > 1024 so no dice.

This reverts commit 10960fd1465afb8de92e8fd35b1affca4f950e27.

  from buildbot.process import buildstep
  from buildbot.process.buildstep import SUCCESS, FAILURE, EXCEPTION
  from buildbot.process.properties import Properties
  from twisted.internet import defer
  
  from ..travisyml import TravisYml
  
  
  class ConfigurableStep(buildstep.LoggingBuildStep):
  
      """
      Base class for a step which can be tuned by changing settings in .travis.yml
      """
  
      @defer.inlineCallbacks
      def getStepConfig(self):
-         config = TravisYml()
- 
-         struct = self.build.getProperty(".travis.yml", None)
-         if struct:
-             config.parse(struct)
-             defer.returnValue(config)
-              
          log = self.addLog(".travis.yml")
          cmd = self.cmd = buildstep.RemoteShellCommand(workdir="build", command=["cat", ".travis.yml"])
          cmd.useLog(log, False, "stdio")
          yield self.runCommand(cmd)
          self.cmd = None
          if cmd.rc != 0:
              raise buildstep.BuildStepFailed()
  
          config = TravisYml()
          config.parse(log.getText())
  
-         self.build.setProperty(".travis.yml", config.config, ".VCS")
- 
          defer.returnValue(config)
  
  
Revert "Save .travis.yml into build properties"
## Code Before:
from buildbot.process import buildstep
from buildbot.process.buildstep import SUCCESS, FAILURE, EXCEPTION
from buildbot.process.properties import Properties
from twisted.internet import defer

from ..travisyml import TravisYml


class ConfigurableStep(buildstep.LoggingBuildStep):

    """
    Base class for a step which can be tuned by changing settings in .travis.yml
    """

    @defer.inlineCallbacks
    def getStepConfig(self):
        config = TravisYml()

        struct = self.build.getProperty(".travis.yml", None)
        if struct:
            config.parse(struct)
            defer.returnValue(config)
             
        log = self.addLog(".travis.yml")
        cmd = self.cmd = buildstep.RemoteShellCommand(workdir="build", command=["cat", ".travis.yml"])
        cmd.useLog(log, False, "stdio")
        yield self.runCommand(cmd)
        self.cmd = None
        if cmd.rc != 0:
            raise buildstep.BuildStepFailed()

        config = TravisYml()
        config.parse(log.getText())

        self.build.setProperty(".travis.yml", config.config, ".VCS")

        defer.returnValue(config)


## Instruction:
Revert "Save .travis.yml into build properties"
## Code After:
from buildbot.process import buildstep
from buildbot.process.buildstep import SUCCESS, FAILURE, EXCEPTION
from buildbot.process.properties import Properties
from twisted.internet import defer

from ..travisyml import TravisYml


class ConfigurableStep(buildstep.LoggingBuildStep):

    """
    Base class for a step which can be tuned by changing settings in .travis.yml
    """

    @defer.inlineCallbacks
    def getStepConfig(self):
        log = self.addLog(".travis.yml")
        cmd = self.cmd = buildstep.RemoteShellCommand(workdir="build", command=["cat", ".travis.yml"])
        cmd.useLog(log, False, "stdio")
        yield self.runCommand(cmd)
        self.cmd = None
        if cmd.rc != 0:
            raise buildstep.BuildStepFailed()

        config = TravisYml()
        config.parse(log.getText())

        defer.returnValue(config)

