def fetch_pack_index(index_url=None, logger=None, allow_empty=False, proxy_config=None):
    """
    Fetch the pack indexes (either from the config or provided as an argument)
    and return the object.
    """
    logger = logger or LOG

    index_urls = _build_index_list(index_url)
    index, status = _fetch_and_compile_index(
        index_urls=index_urls, logger=logger, proxy_config=proxy_config
    )

    # If one of the indexes on the list is unresponsive, we do not throw
    # immediately. The only case where an exception is raised is when no
    # results could be obtained from all listed indexes.
    # This behavior allows for mirrors / backups and handling connection
    # or network issues in one of the indexes.
    if not index and not allow_empty:
        raise ValueError(
            "No results from the %s: tried %s.\nStatus: %s"
            % (
                ("index" if len(index_urls) == 1 else "indexes"),
                ", ".join(index_urls),
                json_encode(status, indent=4),
            )
        )
    return (index, status)

    Fetch the pack indexes (either from the config or provided as an argument)
    and return the object.
    
st2common/st2common/services/packs.py