예제 #1
0
    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))
예제 #2
0
    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))
예제 #3
0
def test_environ(environ):
    from bash import Bash

    bash = Bash(environ=environ)
    env_proc = bash.command("env")
    assert env_proc.ok