Fetch the pack indexes (either from the config or provided as an argument) and return the object.
(index_url=None, logger=None, allow_empty=False, proxy_config=None)
| 166 | |
| 167 | |
| 168 | def fetch_pack_index(index_url=None, logger=None, allow_empty=False, proxy_config=None): |
| 169 | """ |
| 170 | Fetch the pack indexes (either from the config or provided as an argument) |
| 171 | and return the object. |
| 172 | """ |
| 173 | logger = logger or LOG |
| 174 | |
| 175 | index_urls = _build_index_list(index_url) |
| 176 | index, status = _fetch_and_compile_index( |
| 177 | index_urls=index_urls, logger=logger, proxy_config=proxy_config |
| 178 | ) |
| 179 | |
| 180 | # If one of the indexes on the list is unresponsive, we do not throw |
| 181 | # immediately. The only case where an exception is raised is when no |
| 182 | # results could be obtained from all listed indexes. |
| 183 | # This behavior allows for mirrors / backups and handling connection |
| 184 | # or network issues in one of the indexes. |
| 185 | if not index and not allow_empty: |
| 186 | raise ValueError( |
| 187 | "No results from the %s: tried %s.\nStatus: %s" |
| 188 | % ( |
| 189 | ("index" if len(index_urls) == 1 else "indexes"), |
| 190 | ", ".join(index_urls), |
| 191 | json_encode(status, indent=4), |
| 192 | ) |
| 193 | ) |
| 194 | return (index, status) |
| 195 | |
| 196 | |
| 197 | def get_pack_from_index(pack, proxy_config=None): |
no test coverage detected