def METHOD_NAME(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
         on_error='ignore', returncode=False):
    """Run the given command (with shell=False) and return the output as a
    string.
    Strips the output of enclosing whitespace.
    If the return code is non-zero, throw GitInvocationError.
    """
    # start external command process
    p = subprocess.Popen(command, stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE)
    # get outputs
    out, _ = p.communicate()
    # throw exception if process failed
    if p.returncode != 0 and on_error == 'raise':
        raise GitInvocationError('Failed to run "%s"' % " ".join(command))
    out = out.decode('utf-8')
    if returncode:
        return out.strip(), p.returncode
    else:
        return out.strip()