[GRASS-SVN] r71153 - grass/branches/releasebranch_7_2/scripts/v.in.wfs

svn_grass at osgeo.org svn_grass at osgeo.org
Wed May 31 01:55:20 PDT 2017


Author: neteler
Date: 2017-05-31 01:55:20 -0700 (Wed, 31 May 2017)
New Revision: 71153

Modified:
   grass/branches/releasebranch_7_2/scripts/v.in.wfs/v.in.wfs.py
Log:
v.in.wfs: Move WFS import to urllib2 to provide better error messages. Fixes #3324 (trunk, r70823)

Modified: grass/branches/releasebranch_7_2/scripts/v.in.wfs/v.in.wfs.py
===================================================================
--- grass/branches/releasebranch_7_2/scripts/v.in.wfs/v.in.wfs.py	2017-05-30 22:32:54 UTC (rev 71152)
+++ grass/branches/releasebranch_7_2/scripts/v.in.wfs/v.in.wfs.py	2017-05-31 08:55:20 UTC (rev 71153)
@@ -79,9 +79,10 @@
 from grass.script.utils import try_remove
 from grass.script import core as grass
 try:
-    from urllib import urlopen
+    from urllib2 import urlopen, URLError, HTTPError
 except ImportError:
     from urllib.request import urlopen
+    from urllib.error import URLError, HTTPError
 
 
 def main():
@@ -120,7 +121,16 @@
     grass.debug(wfs_url)
 
     grass.message(_("Retrieving data..."))
-    inf = urlopen(wfs_url)
+    try:
+        inf = urlopen(wfs_url)
+    except HTTPError as e:
+        # GTC WFS request HTTP failure
+        grass.fatal(_("The server couldn't fulfill the request.\nError code: %s") % e.code)
+    except URLError as e:
+        # GTC WFS request network failure
+        grass.fatal(_("Failed to reach the server.\nReason: %s") % e.reason)
+        
+    
     outf = file(tmpxml, 'wb')
     while True:
         s = inf.read()



More information about the grass-commit mailing list