def execute(self): bash = Bash() logger = logging.getLogger('script') for instruction in self.instructions: logger.info(" + %s" % instruction) command = bash.command(instruction) for line in command.output.splitlines(): logger.info(" %s" % line) for line in command.err.splitlines(): logger.warning(" %s" % line) if command.return_code != 0: raise ExecutionFailed("%s exited with code %s" % (instruction, command.return_code))
def execute(self, instructions): if not instructions: return bash = Bash() logger = logging.getLogger(self.namespace) if isinstance(instructions, str): instructions = instructions.splitlines() for instruction in instructions: logger.info(" + %s" % instruction) command = bash.command(instruction) for line in command.output.splitlines(): logger.info(" %s" % line) for line in command.err.splitlines(): logger.warning(" %s" % line) if command.return_code != 0: raise ExecutionFailed("%s exited with code %s" % (instruction, command.return_code))
def test_environ(environ): from bash import Bash bash = Bash(environ=environ) env_proc = bash.command("env") assert env_proc.ok