From e4b2742192ebaf5654a601e2181bee04422be823 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 12 Apr 2021 15:58:52 +0200 Subject: Adding some error handling to list_mirrors() --- archinstall/lib/mirrors.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'archinstall/lib/mirrors.py') diff --git a/archinstall/lib/mirrors.py b/archinstall/lib/mirrors.py index d7d35782..04f47c0d 100644 --- a/archinstall/lib/mirrors.py +++ b/archinstall/lib/mirrors.py @@ -74,10 +74,15 @@ def re_rank_mirrors(top=10, *positionals, **kwargs): def list_mirrors(): url = f"https://archlinux.org/mirrorlist/?protocol=https&ip_version=4&ip_version=6&use_mirror_status=on" - - response = urllib.request.urlopen(url) regions = {} + try: + response = urllib.request.urlopen(url) + except urllib.error.URLError as err: + log(f'Could not fetch an active mirror-list: {err}', level=LOG_LEVELS.Warning, fg="yellow") + return regions + + region = 'Unknown region' for line in response.readlines(): if len(line.strip()) == 0: -- cgit v1.2.3-70-g09d2