[GRASS-SVN] r70997 - grass-addons/grass7/raster/r.in.wcs

svn_grass at osgeo.org svn_grass at osgeo.org
Mon May 1 19:39:24 PDT 2017


Author: wenzeslaus
Date: 2017-05-01 19:39:23 -0700 (Mon, 01 May 2017)
New Revision: 70997

Modified:
   grass-addons/grass7/raster/r.in.wcs/r.in.wcs.py
Log:
r.in.wcs: fallback to xml package when lxml is not available

Modified: grass-addons/grass7/raster/r.in.wcs/r.in.wcs.py
===================================================================
--- grass-addons/grass7/raster/r.in.wcs/r.in.wcs.py	2017-05-02 00:49:05 UTC (rev 70996)
+++ grass-addons/grass7/raster/r.in.wcs/r.in.wcs.py	2017-05-02 02:39:23 UTC (rev 70997)
@@ -104,9 +104,17 @@
 import urllib2
 from httplib import HTTPException
 import subprocess
-import lxml.etree as etree
 
+try:
+    import lxml.etree as etree
+    LXML_AVAILABLE = True
+except ImportError:
+    # this fallback is not thoroughly tested but works when
+    # just starting the module and lxml is not available
+    import xml.etree.ElementTree as etree
+    LXML_AVAILABLE = False
 
+
 class WCSBase:
     def __init__(self):
         # these variables are information for destructor
@@ -445,6 +453,10 @@
 
     options['version']="1.0.0" # right now only supported version, therefore not in GUI
 
+    if not LXML_AVAILABLE:
+        grass.warning("The Python lxml is not installed."
+                      " The functionality may be limited.")
+
     grass.debug("Using GDAL WCS driver")
     wcs = WCSGdalDrv()  # only supported driver
 



More information about the grass-commit mailing list