(self)
return res
Execute a command (a list or string) with input_text as input, appending
        the output of all commands to the build log.

        This code was derived from http://vespene.io/ though is slightly different
        because there are no database objects.
Execute a command (a list or string) with input_text as input, appending
        the output of all commands to the build log.
Execute a command ( a list or string ) with input_text as input appending the output of all commands to the build log .
def execute(self):
        """
        Execute a command (a list or string) with input_text as input, appending
        the output of all commands to the build log.

        This code was derived from http://vespene.io/ though is slightly different
        because there are no database objects.
        """

        Callbacks().on_execute_command(self.provider, self)
        
        command = self.cmd
        timeout_cmd = self.get_timeout()

        shell = True
        if type(command) == list:
            if self.timeout and timeout_cmd:
                command.insert(0, str(self.timeout))
                command.insert(0, timeout_cmd)
            shell = False
        else:
            if self.timeout and timeout_cmd:
                command = "%s %s %s" % (timeout_cmd, self.timeout, command)

        # keep SSH-agent working for executed commands
        sock = os.environ.get('SSH_AUTH_SOCK', None)
        if self.env and sock:
            self.env['SSH_AUTH_SOCK'] = sock

        process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=shell, env=self.env)

        if self.input_text is None:
            self.input_text = ""

        stdin = io.TextIOWrapper(
            process.stdin,
            encoding='utf-8',
            line_buffering=True,
        )
        stdout = io.TextIOWrapper(
            process.stdout,
            encoding='utf-8',
        )
        stdin.write(self.input_text)
        stdin.close()

        output = ""
        for line in stdout:
            if (self.echo or self.loud) and (not self.ignore_lines or not self.should_ignore(line)):
                Callbacks().on_command_echo(self.provider, line)
            output = output + line
        if output.strip() == "":
            Callbacks().on_command_echo(self.provider, "(no output)")


        process.wait()

        res = None
        rc = process.returncode
        if rc != 0:
            res = Result(self.provider, rc=rc, data=output, fatal=self.fatal, primary=self.primary)
        else:
            res = Result(self.provider, rc=rc, data=output, fatal=False, primary=self.primary)
        Callbacks().on_command_result(self.provider, res)
        if res.fatal:
            raise FailedResult(provider=self.provider, result=res)
        return res
def execute ( self ) : Callbacks ( ) . on_execute_command ( self . provider , self ) command = self . cmd timeout_cmd = self . get_timeout ( ) shell = True if type ( command ) == list : if self . timeout and timeout_cmd : command . insert ( 0 , str ( self . timeout ) ) command . insert ( 0 , timeout_cmd ) shell = False else : if self . timeout and timeout_cmd : command = "%s %s %s" % ( timeout_cmd , self . timeout , command ) # keep SSH-agent working for executed commands sock = os . environ . get ( 'SSH_AUTH_SOCK' , None ) if self . env and sock : self . env [ 'SSH_AUTH_SOCK' ] = sock process = subprocess . Popen ( command , stdin = subprocess . PIPE , stdout = subprocess . PIPE , stderr = subprocess . STDOUT , shell = shell , env = self . env ) if self . input_text is None : self . input_text = "" stdin = io . TextIOWrapper ( process . stdin , encoding = 'utf-8' , line_buffering = True , ) stdout = io . TextIOWrapper ( process . stdout , encoding = 'utf-8' , ) stdin . write ( self . input_text ) stdin . close ( ) output = "" for line in stdout : if ( self . echo or self . loud ) and ( not self . ignore_lines or not self . should_ignore ( line ) ) : Callbacks ( ) . on_command_echo ( self . provider , line ) output = output + line if output . strip ( ) == "" : Callbacks ( ) . on_command_echo ( self . provider , "(no output)" ) process . wait ( ) res = None rc = process . returncode if rc != 0 : res = Result ( self . provider , rc = rc , data = output , fatal = self . fatal , primary = self . primary ) else : res = Result ( self . provider , rc = rc , data = output , fatal = False , primary = self . primary ) Callbacks ( ) . on_command_result ( self . provider , res ) if res . fatal : raise FailedResult ( provider = self . provider , result = res ) return res