joey: thuban/Extensions/wms capabilities.py,1.3,1.4
cvs@intevation.de
cvs at intevation.de
Thu Apr 1 11:58:32 CEST 2004
Author: joey
Update of /thubanrepository/thuban/Extensions/wms
In directory doto:/tmp/cvs-serv18514
Modified Files:
capabilities.py
Log Message:
Misc corrections:
. superflous asterisk
. Documentation for __init__
. Syntax correction
. fetchCapabilities: Initialise variable, use local one
. loadCapabilities: Use local variable
. Fix try...except to only cat IOError when handling files
. Corrected __main__ code
Index: capabilities.py
===================================================================
RCS file: /thubanrepository/thuban/Extensions/wms/capabilities.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- capabilities.py 24 Mar 2004 20:07:34 -0000 1.3
+++ capabilities.py 1 Apr 2004 09:58:30 -0000 1.4
@@ -24,7 +24,7 @@
getErrorMsg()
- fetchCapabilities(*resource)
+ fetchCapabilities(resource)
saveCapabilities(filename)
loadCapabilities(filename)
printCapabilities()
@@ -89,6 +89,8 @@
"""
Initialises Capabilities with one optional parameter
+ param can be either a URL or a filename:
+
filename -- load capabilities from file
url -- fetch capabilities from network
"""
@@ -101,8 +103,8 @@
self.fetchCapabilities(parm[0])
else:
self.errorMsg \
- = _("Resource '%s' is neither local file nor URL")
- % parm[0]
+ = _("Resource '%s' is neither local file nor URL") \
+ % parm[0]
def getErrorMsg(self):
@@ -112,11 +114,12 @@
def fetchCapabilities(self, resource):
"""Fetches the WMS capabilities from an Internet resource"""
+ xml = None
self.wmsVersion = "1.1"
- self.capabilities = self.getCapabilities(resource, self.wmsVersion)
+ xml = self.getCapabilities(resource, self.wmsVersion)
if not self.capabilities:
self.wmsVersion = "1.0"
- self.capabilities = self.getCapabilities(resource, self.wmsVersion)
+ xml = self.getCapabilities(resource, self.wmsVersion)
def saveCapabilities(self, fname):
@@ -129,7 +132,7 @@
out = open(fname, "w")
out.write(self.capabilities)
out.close()
- except:
+ except IOError:
self.errorMsg = _("Can't open file '%s' for writing") % fname
@@ -138,9 +141,9 @@
try:
input = open(fname, "r")
- self.capabilities = input.read()
+ xml = input.read()
input.close()
- except:
+ except IOError:
self.errorMsg = _("Can't open file '%s' for reading") % fname
@@ -154,7 +157,7 @@
if __name__ == "__main__":
capabilities \
= WMSCapabilities("http://frida.intevation.org/cgi-bin/frida_wms?")
- if capa.getErrorMsg() is None:
- capa.saveCapabilities("frida_capabilities.xml")
+ if capabilities.getErrorMsg() is None:
+ capabilities.saveCapabilities("frida_capabilities.xml")
else:
- print "Error: " + capa.getErrorMsg()
+ print "Error: " + capabilities.getErrorMsg()
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)