[GRASS-SVN] r37064 - grass/trunk/scripts/r.in.wms

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 9 09:34:25 EDT 2009


Author: martinl
Date: 2009-05-09 09:34:25 -0400 (Sat, 09 May 2009)
New Revision: 37064

Modified:
   grass/trunk/scripts/r.in.wms/r.in.wms.py
Log:
r.in.wms: fix cap_file option


Modified: grass/trunk/scripts/r.in.wms/r.in.wms.py
===================================================================
--- grass/trunk/scripts/r.in.wms/r.in.wms.py	2009-05-09 12:47:56 UTC (rev 37063)
+++ grass/trunk/scripts/r.in.wms/r.in.wms.py	2009-05-09 13:34:25 UTC (rev 37064)
@@ -192,14 +192,22 @@
     
     # download capabilities file
     grass.verbose("List of layers for server <%s>:" % options['mapserver'])
-    cap_file = urllib.urlopen(options['mapserver'] + '?' + qstring)
-    if not cap_file:
+    url = options['mapserver'] + '?' + qstring
+    try:
+        if options['cap_file']:
+            cap_file = urllib.urlretrieve(url, options['cap_file'])
+        else:
+            cap_file = urllib.urlopen(url, options['mapserver'] + '?' + qstring)
+    except IOError:
         grass.fatal("Unable to get capabilities of '%s'" % options['mapserver'])
     
     # parse file with sax
     cap_xml = wms_parse.ProcessCapFile()
     try:
-        xml.sax.parse(cap_file, cap_xml)
+        if options['cap_file']:
+            xml.sax.parse(options['cap_file'], cap_xml)
+        else:
+            xml.sax.parse(cap_file, cap_xml)
     except xml.sax.SAXParseException, err:
         grass.fatal("Reading capabilities failed. "
                     "Unable to parse XML document: %s" % err)
@@ -214,6 +222,9 @@
     elif not options['output']:
         grass.fatal("No output map specified")
     
+    if options['cap_file'] and not flags['l']:
+        grass.warning("Option <cap_file> ignored. It requires '-l' flag.")
+    
     # set directory for download
     if not options['folder']:
         options['folder'] = os.path.join(grass.gisenv()['GISDBASE'], 'wms_download')



More information about the grass-commit mailing list