def run_command(self, cmd, input_data=None):
kwargs = {<EOL>'<STR_LIT>': subprocess.PIPE,<EOL>'<STR_LIT>': subprocess.PIPE,<EOL>}<EOL>if input_data is not None:<EOL><INDENT>kwargs['<STR_LIT>'] = subprocess.PIPE<EOL><DEDENT>stdout = []<EOL>stderr = []<EOL>p = subprocess.Popen(cmd, **kwargs)<EOL>t1 = Thread(target=self._reader, args=('<STR_LIT>', p.stdout, stdout))<EOL>t1.start()<EOL>t2 = Thread(target=self._reader, args=('<STR_LIT>', p.stderr, stderr))<EOL>t2.start()<EOL>if input_data is not None:<EOL><INDENT>p.stdin.write(input_data)<EOL>p.stdin.close()<EOL><DEDENT>p.wait()<EOL>t1.join()<EOL>t2.join()<EOL>return p.returncode, stdout, stderr<EOL>
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``.