def run_through_shell(command, enable_shell=False):
if not enable_shell and isinstance(command, str):<EOL><INDENT>command = shlex.split(command)<EOL><DEDENT>returncode = None<EOL>stderr = None<EOL>try:<EOL><INDENT>proc = subprocess.Popen(command, stderr=subprocess.PIPE,<EOL>stdout=subprocess.PIPE, shell=enable_shell)<EOL>out, stderr = proc.communicate()<EOL>out = out.decode("<STR_LIT>")<EOL>stderr = stderr.decode("<STR_LIT>")<EOL>returncode = proc.returncode<EOL><DEDENT>except OSError as e:<EOL><INDENT>out = e.strerror<EOL>stderr = e.strerror<EOL>logging.getLogger("<STR_LIT>").exception("<STR_LIT>")<EOL><DEDENT>except subprocess.CalledProcessError as e:<EOL><INDENT>out = e.output<EOL>logging.getLogger("<STR_LIT>").exception("<STR_LIT>")<EOL><DEDENT>return CommandResult(returncode, out, stderr)<EOL>
Retrieve output of a command.
Returns a named tuple with three elements:

* ``rc`` (integer) Return code of command.
* ``out`` (string) Everything that was printed to stdout.
* ``err`` (string) Everything that was printed to stderr.

Don't use this function with programs that outputs lots of data since the
output is saved in one variable.

:param command: A string or a list of strings containing the name and
 arguments of the program.
:param enable_shell: If set ot `True` users default shell will be invoked
 and given ``command`` to execute. The ``command`` should obviously be a
 string since shell does all the parsing.