[elbe-devel] [PATCH 1/2] xmlpreprocess: also raise XMLPreprocessError for URLError
Bastian Germann
bage at linutronix.de
Thu Jul 22 22:02:12 CEST 2021
Am 22.07.21 um 17:25 schrieb Torben Hohn:
> When the host can not be resolved/connected URLError is raised.
> In that case its unclear, which URL triggers the problem.
>
> Also catch URLError and raise a similar message, but
> slightly different, so its possible to discriminate the error.
>
> Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
Reviewed-by: Bastian Germann <bage at linutronix.de>
> ---
> elbepack/xmlpreprocess.py | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/elbepack/xmlpreprocess.py b/elbepack/xmlpreprocess.py
> index b991c6ea7..b330f1033 100644
> --- a/elbepack/xmlpreprocess.py
> +++ b/elbepack/xmlpreprocess.py
> @@ -12,7 +12,7 @@ import sys
> from tempfile import NamedTemporaryFile
> from optparse import OptionGroup
> from itertools import islice
> -from urllib.error import HTTPError
> +from urllib.error import HTTPError,URLError
> from urllib.request import urlopen
>
> from lxml import etree
> @@ -49,6 +49,9 @@ def preprocess_pgp_key(xml):
> except HTTPError:
> raise XMLPreprocessError("Invalid PGP Key URL in <key> tag: %s" %
> keyurl)
> + except URLError:
> + raise XMLPreprocessError("Problem with PGP Key URL in <key> tag: %s" %
> + keyurl)
>
>
> def preprocess_iso_option(xml):
>
More information about the elbe-devel
mailing list