From a65606cbfe9ef216eee22646fadac3767afe8caf Mon Sep 17 00:00:00 2001 From: lethliel Date: Tue, 6 Nov 2018 13:29:17 +0100 Subject: [PATCH] fix broken URLError handling in OscMirrorGroup.urlgrab() If urlgrab returns a URLError (for example if the Network is unreachable) the for loop did not continue and the osc build aborts. Now we also catch the URLError and try the next mirror and return False correctly if no mirror could be reached. And then try to download it from api --- osc/grabber.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/osc/grabber.py b/osc/grabber.py index f9915a3f..b8e4441a 100644 --- a/osc/grabber.py +++ b/osc/grabber.py @@ -11,10 +11,12 @@ try: from urllib.request import HTTPError from urllib.parse import urlparse from urllib.parse import unquote + from urllib.error import URLError except ImportError: from urllib2 import HTTPError from urlparse import urlparse from urllib import unquote + from urllib2 import URLError class OscFileGrabber(object): @@ -37,12 +39,12 @@ class OscMirrorGroup(object): self._mirrors = mirrors def urlgrab(self, url, filename=None, text=None): - tries = 0 for mirror in self._mirrors: try: self._grabber.urlgrab(mirror, filename, text) return True - except HTTPError as e: - tries += 1 + except (HTTPError, URLError) as e: + # try next mirror + pass return False