Run a command using subprocess.

    :param command: command line to be run
    :type command: str
    :param raw_output: does not attempt to convert the output as unicode
    :type raw_output: bool
    :return: error code, output (``stdout``) and error (``stderr``)
    :rtype: tuple

def run(command, raw_output=False):
    """Run a command using subprocess.

    :param command: command line to be run
    :type command: str
    :param raw_output: does not attempt to convert the output as unicode
    :type raw_output: bool
    :return: error code, output (``stdout``) and error (``stderr``)
    :rtype: tuple

    """
    p = Popen(command.split(), stdout=PIPE, stderr=PIPE)
    (stdout, stderr) = p.communicate()
    # On python 3, subprocess.Popen returns bytes objects.
    if not raw_output:
        return (
            p.returncode,
            [line.rstrip() for line in stdout.decode("utf-8").splitlines()],
            [line.rstrip() for line in stderr.decode("utf-8").splitlines()]
        )
    else:
        return (p.returncode, stdout, stderr)