def METHOD_NAME(cmd, input=None, log=None, extrafiles=None, **options):
    """Convenience function to run a command and return its output, raising an
    exception when the command fails"""
    if not extrafiles:
        extrafiles = []
    if isinstance(cmd, str) and not "shell" in options:
        options["shell"] = True
    try:
        pipe = Popen(cmd, **options)
    except OSError as exc:
        if exc.errno == 2:
            raise NotFoundError(cmd)
        else:
            raise CmdError(cmd, exc)
    if log:
        stdout, stderr = _logged_communicate(pipe, log, input, extrafiles)
    else:
        stdout, stderr = pipe.communicate(input)
        if not stdout is None:
            stdout = stdout.decode("utf-8")
        if not stderr is None:
            stderr = stderr.decode("utf-8")
    if pipe.returncode != 0:
        if log:
            # Don't duplicate the output in the exception if logging it
            raise ExecutionError(cmd, pipe.returncode, None, None)
        raise ExecutionError(cmd, pipe.returncode, stdout, stderr)
    return stdout, stderr