'Returns the stdout and stderr of a command being run.'

def run_shell_command(self):

    (stdout_str, stderr_str) = ('', '')
    command = ((self.shell_command + '    ') + (self.args or ''))
    if self.run_in_shell:
        command = _escape_shell_command(command)
    else:
        command = shlex.split(command.encode('ascii'))
    try:
        proc = subprocess.Popen(command, shell=bool(self.run_in_shell), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        (stdout_str, stderr_str) = proc.communicate()
        if proc.returncode:
            stderr_str += ('\n\n***    Process    ended    with    return    code    %d\n\n' % proc.returncode)
        self.last_run_successful = (not proc.returncode)
    except Exception as e:
        stderr_str += self._get_exception_string(e, sys.exc_info())
        self.last_run_successful = False
    return (stdout_str, stderr_str)
