From 60ad5a75239645b5b48df2c2132cf73c07b3b6c4 Mon Sep 17 00:00:00 2001 From: Ondrej Pesek Date: Thu, 12 Dec 2024 11:14:50 +0100 Subject: [PATCH] v.in.wfs: improve error message for ServiceException (#4812) the current one said that the downloaded XML cannot be found - report the meaningful content of service exception report instead --- scripts/v.in.wfs/v.in.wfs.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/v.in.wfs/v.in.wfs.py b/scripts/v.in.wfs/v.in.wfs.py index 2949949ad50..ead40698fbd 100755 --- a/scripts/v.in.wfs/v.in.wfs.py +++ b/scripts/v.in.wfs/v.in.wfs.py @@ -227,7 +227,14 @@ def main(): grass.run_command("v.in.ogr", flags="o", input=tmpxml, output=out) grass.message(_("Vector map <%s> imported from WFS.") % out) except Exception: + import xml.etree.ElementTree as ET + grass.message(_("WFS import failed")) + + root = ET.parse(tmpxml).getroot() + if "ServiceExceptionReport" in root.tag: + se = root.find(root.tag[:-6]) # strip "Report" from the tag + grass.message(se.text.strip()) finally: try_remove(tmpxml)