|
10 | 10 | import shutil |
11 | 11 | import sqlite3 |
12 | 12 | import subprocess |
| 13 | +import sys |
13 | 14 | import xml.etree.ElementTree as ET |
14 | 15 | from pathlib import Path |
15 | 16 | from typing import List |
16 | 17 | from typing import Optional |
17 | 18 | from typing import Union |
| 19 | +from urllib.error import HTTPError |
18 | 20 |
|
19 | 21 | from drgn_tools.util import download_file |
20 | 22 | from testing.util import BASE_DIR |
@@ -210,22 +212,28 @@ def _get_rpms(self) -> None: |
210 | 212 | self._getlatest() |
211 | 213 |
|
212 | 214 | self._rpm_paths = [] |
213 | | - for i, url in enumerate(self._rpm_urls): |
| 215 | + try: |
| 216 | + for i, url in enumerate(self._rpm_urls): |
| 217 | + path = download_file_cached( |
| 218 | + url, |
| 219 | + desc=f"RPM {i + 1}/{len(self._rpm_urls)}", |
| 220 | + cache=self.cache_dir, |
| 221 | + cache_key=self._cache_key("rpm"), |
| 222 | + delete_on_miss=(i == 0), |
| 223 | + ) |
| 224 | + self._rpm_paths.append(path) |
214 | 225 | path = download_file_cached( |
215 | | - url, |
216 | | - desc=f"RPM {i + 1}/{len(self._rpm_urls)}", |
| 226 | + self._dbinfo_url, |
| 227 | + desc="Debuginfo RPM", |
217 | 228 | cache=self.cache_dir, |
218 | 229 | cache_key=self._cache_key("rpm"), |
219 | | - delete_on_miss=(i == 0), |
| 230 | + delete_on_miss=False, |
| 231 | + ) |
| 232 | + except HTTPError as e: |
| 233 | + sys.exit( |
| 234 | + f"HTTP error {e.code} {e.reason} encountered while " |
| 235 | + f"fetching URL:\n{e.url}" |
220 | 236 | ) |
221 | | - self._rpm_paths.append(path) |
222 | | - path = download_file_cached( |
223 | | - self._dbinfo_url, |
224 | | - desc="Debuginfo RPM", |
225 | | - cache=self.cache_dir, |
226 | | - cache_key=self._cache_key("rpm"), |
227 | | - delete_on_miss=False, |
228 | | - ) |
229 | 237 | self._dbinfo_path = path |
230 | 238 |
|
231 | 239 | def get_rpms(self) -> List[Path]: |
|
0 commit comments