(self, cmd, input_data=None)
return p.returncode, stdout, stderr
Run a command in a child process , passing it any input data specified.

        :param cmd: The command to run.
        :param input_data: If specified, this must be a byte string containing
                           data to be sent to the child process.
        :return: A tuple consisting of the subprocess' exit code, a list of
                 lines read from the subprocess' ``stdout``, and a list of
                 lines read from the subprocess' ``stderr``.
Run a command in a child process , passing it any input data specified.
Run a command in a child process passing it any input data specified .
def run_command(self, cmd, input_data=None):
        """
        Run a command in a child process , passing it any input data specified.

        :param cmd: The command to run.
        :param input_data: If specified, this must be a byte string containing
                           data to be sent to the child process.
        :return: A tuple consisting of the subprocess' exit code, a list of
                 lines read from the subprocess' ``stdout``, and a list of
                 lines read from the subprocess' ``stderr``.
        """
        kwargs = {
            'stdout': subprocess.PIPE,
            'stderr': subprocess.PIPE,
        }
        if input_data is not None:
            kwargs['stdin'] = subprocess.PIPE
        stdout = []
        stderr = []
        p = subprocess.Popen(cmd, **kwargs)
        # We don't use communicate() here because we may need to
        # get clever with interacting with the command
        t1 = Thread(target=self._reader, args=('stdout', p.stdout, stdout))
        t1.start()
        t2 = Thread(target=self._reader, args=('stderr', p.stderr, stderr))
        t2.start()
        if input_data is not None:
            p.stdin.write(input_data)
            p.stdin.close()

        p.wait()
        t1.join()
        t2.join()
        return p.returncode, stdout, stderr
def run_command ( self , cmd , input_data = None ) : kwargs = { 'stdout' : subprocess . PIPE , 'stderr' : subprocess . PIPE , } if input_data is not None : kwargs [ 'stdin' ] = subprocess . PIPE stdout = [ ] stderr = [ ] p = subprocess . Popen ( cmd , * * kwargs ) # We don't use communicate() here because we may need to # get clever with interacting with the command t1 = Thread ( target = self . _reader , args = ( 'stdout' , p . stdout , stdout ) ) t1 . start ( ) t2 = Thread ( target = self . _reader , args = ( 'stderr' , p . stderr , stderr ) ) t2 . start ( ) if input_data is not None : p . stdin . write ( input_data ) p . stdin . close ( ) p . wait ( ) t1 . join ( ) t2 . join ( ) return p . returncode , stdout , stderr