[Pywps-commits] r1170 - in branches/pywps-3.2-soap: pywps/Wps/Execute tests tests/processes tests/requests
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Jul 8 16:29:57 CEST 2011
Author: jesus
Date: 2011-07-08 16:29:56 +0200 (Fri, 08 Jul 2011)
New Revision: 1170
Added:
branches/pywps-3.2-soap/tests/requests/wps_execute_request_lineage.xml
branches/pywps-3.2-soap/tests/requests/wps_execute_request_reference_lineage.xml
Modified:
branches/pywps-3.2-soap/pywps/Wps/Execute/__init__.py
branches/pywps-3.2-soap/tests/perform_requests.py
branches/pywps-3.2-soap/tests/processes/moreInOne.py
branches/pywps-3.2-soap/tests/processes/tests.py
Log:
FEATURE: Lineage for Multiple ComplexInput for one WPS input
Modified: branches/pywps-3.2-soap/pywps/Wps/Execute/__init__.py
===================================================================
--- branches/pywps-3.2-soap/pywps/Wps/Execute/__init__.py 2011-07-07 14:44:19 UTC (rev 1169)
+++ branches/pywps-3.2-soap/pywps/Wps/Execute/__init__.py 2011-07-08 14:29:56 UTC (rev 1170)
@@ -39,6 +39,7 @@
from xml.sax.saxutils import escape
+
TEMPDIRPREFIX="pywps-instance"
#Note: saxutils to escape &,< and > from URLs. Applied to _lineageComplexRerenceInput,_asReferenceOutput. in the last case
@@ -721,7 +722,6 @@
templateInputs = []
for identifier in self.process.inputs.keys():
input = self.process.inputs[identifier]
-
for wpsInput in self.wps.inputs["datainputs"]:
if wpsInput["identifier"] != identifier or\
wpsInput.has_key("lineaged"):
@@ -741,13 +741,11 @@
templateInput = self._lineageComplexReferenceInput(wpsInput,
input,templateInput)
elif input.type == "ComplexValue":
- templateInput = self._lineageComplexInput(input,templateInput)
+ templateInput = self._lineageComplexInput(wpsInput,templateInput)
elif input.type == "BoundingBoxValue":
templateInput = self._lineageBBoxInput(input,templateInput)
-
templateInputs.append(templateInput)
-
self.templateProcessor.set("Inputs",templateInputs)
def _lineageLiteralInput(self, input, wpsInput, literalInput):
@@ -757,23 +755,16 @@
literalInput["uom"] = str(input.uom)
return literalInput
- def _lineageComplexInput(self, input, complexInput):
+ def _lineageComplexInput(self, wpsInput,complexInput):
""" Fill input of complex data
"""
-
- # encode the input file, if it has non-text mimetype
- if input.format["mimetype"].find("text") < 0:
- #complexInput["cdata"] = 1
- os.rename(input.value, input.value+".binary")
- base64.encode(open(input.value+".binary"),open(input.value,"w"))
-
- # set complex input
- complexInput["complexdata"] = open(input.value,"r").read()
+
+ #complexInput needs to be replicated
+ complexInput["encoding"]=wpsInput["encoding"]
+ complexInput["mimetype"]=wpsInput["mimetype"]
+ complexInput["schema"]=wpsInput["schema"]
+ complexInput["complexdata"]=wpsInput["value"]
-
- complexInput["encoding"] = input.format["encoding"]
- complexInput["mimetype"] = input.format["mimetype"]
- complexInput["schema"] = input.format["schema"]
return complexInput
def _lineageComplexReferenceInput(self, wpsInput, processInput, complexInput):
@@ -802,8 +793,9 @@
def _lineageBBoxInput(self,input,bboxInput):
""" Fill input of bbox data """
+
bboxInput["bboxdata"] = 1
- bboxInput["crs"] = input.crs
+ bboxInput["crs"] = input.value.crs
bboxInput["dimensions"] = input.value.dimensions
#((minx,miny),(maxx, maxy))
@@ -843,8 +835,7 @@
templateOutput["complexdata"] = 1
else:
templateOutput = self._lineageBBoxOutput(output,templateOutput)
- templateOutput["bboxdata"] = 1
-
+ templateOutput["bboxdata"] = 1
self.templateProcessor.set("Outputdefinitions",templateOutputs)
def _lineageLiteralOutput(self, output, literalOutput):
@@ -863,7 +854,7 @@
return complexOutput
def _lineageBBoxOutput(self, output, bboxOutput):
-
+
bboxOutput["bboxdata"] = 1
bboxOutput["crs"] = output.crs
bboxOutput["dimensions"] = output.dimensions
Modified: branches/pywps-3.2-soap/tests/perform_requests.py
===================================================================
--- branches/pywps-3.2-soap/tests/perform_requests.py 2011-07-07 14:44:19 UTC (rev 1169)
+++ branches/pywps-3.2-soap/tests/perform_requests.py 2011-07-08 14:29:56 UTC (rev 1170)
@@ -2,9 +2,8 @@
import sys
pywpsPath = os.path.abspath(os.path.join(os.path.split(os.path.abspath(__file__))[0],".."))
-
-sys.path.append(pywpsPath)
-
+#sys.path.append(pywpsPath)
+sys.path[0]=pywpsPath
import pywps
import pywps.Process
import unittest
@@ -34,6 +33,7 @@
wcsurl = "http://www.bnhelp.cz/cgi-bin/crtopo?service=WMS&request=GetMap&LAYERS=sitwgs&TRANSPARENT=true&FORMAT=image%2Ftiff&EXCEPTIONS=application%2Fvnd.ogc.se_xml&VERSION=1.1.1&STYLES=default&SRS=EPSG%3A4326&BBOX=-10,-10,10,10&WIDTH=50&HEIGHT=50"
wpsns = "http://www.opengis.net/wps/1.0.0"
owsns = "http://www.opengis.net/ows/1.1"
+ ogrns = "http://ogr.maptools.org/"
xmldom = None
def setUp(self):
@@ -297,6 +297,7 @@
def test14ParseExecuteResponseDocumentGET(self):
"""Return a response document that only containts the requested ouputs """
+ self._setFromEnv()
import urllib
getpywps = pywps.Pywps(pywps.METHOD_GET)
@@ -323,7 +324,7 @@
"""Return a response document that only containts the requested ouputs, from an XML request
lineage output will also be checked
"""
-
+ self._setFromEnv()
import urllib
postpywps = pywps.Pywps(pywps.METHOD_POST)
executeRequestFile = open(os.path.join(pywpsPath,"tests","requests","wps_execute_request-complexinput-one-output-as-reference.xml"))
@@ -344,7 +345,62 @@
identifierNodes=processOutNodes[0].getElementsByTagNameNS(self.owsns,"Identifier")
self.assertEquals(identifierNodes[0].firstChild.nodeValue,"rasterout")
-
+ def test16ParseLineageResponseDocumentPost(self):
+ """if Return response document contain lineage, lineage shall be identical to Execute input, even for multiple inputs"""
+
+ self._setFromEnv()
+ import hashlib
+
+ imgPNGHashOriginal="b95e7e25c8c3897452a1f164da6d8c83"
+ imgBMPHashOriginal="ed3a7fa929dc5236dd12667eb19c6a6c"
+
+ postpywps = pywps.Pywps(pywps.METHOD_POST)
+ executeRequestFile = open(os.path.join(pywpsPath,"tests","requests","wps_execute_request_lineage.xml"))
+ postpywps.parseRequest(executeRequestFile)
+ postpywps.performRequest()
+ postxmldom = minidom.parseString(postpywps.response)
+ dataInputsDom=postxmldom.getElementsByTagNameNS(self.wpsns,"DataInputs")
+ #Check lineage presence
+ self.assertTrue(len(dataInputsDom)>0)
+
+ inputDom=dataInputsDom[0].getElementsByTagNameNS(self.wpsns,"Input")
+
+ #Check lineage size (number elements)
+ self.assertEquals(len(inputDom),6)
+
+ idNameList=[input.getElementsByTagNameNS(self.owsns,"Identifier")[0].childNodes[0].nodeValue for input in inputDom ]
+
+ #Check number lineage for raster,vector,bboxin (2 of each)
+ len([id for id in idNameList if id=="rasterin"])
+ self.assertEquals(len([id for id in idNameList if id=="rasterin"]),2)
+ self.assertEquals(len([id for id in idNameList if id=="vectorin"]),2)
+ self.assertEquals(len([id for id in idNameList if id=="bboxin"]),2)
+
+ complexDataDom=dataInputsDom[0].getElementsByTagNameNS(self.wpsns,"ComplexData")
+ xmlNodes=[item for item in complexDataDom if (item.getAttribute("mimeType")=="text/xml" or item.getAttribute("mimeType")=="application/xml")]
+ ogrNodes=[node.getElementsByTagNameNS(self.ogrns,"FeatureCollection") for node in xmlNodes]
+
+ #Checking FeatureCollection in XML payload
+ self.assertEquals(len(ogrNodes),2)
+
+ #getting png image
+ imgPNGLineage=[item.childNodes[0].toxml().strip() for item in complexDataDom if item.getAttribute("mimeType")=="image/png"][0]
+ imgBMPLineage=[item.childNodes[0].toxml().strip() for item in complexDataDom if item.getAttribute("mimeType")=="image/bmp"][0]
+ imgPNGHash=hashlib.md5(imgPNGLineage).hexdigest() #b95e7e25c8c3897452a1f164da6d8c83
+ imgBMPHash=hashlib.md5(imgBMPLineage).hexdigest() #ed3a7fa929dc5236dd12667eb19c6a6c
+
+ self.assertEquals(imgPNGHash,imgPNGHashOriginal)
+ self.assertEquals(imgBMPHash,imgBMPHashOriginal)
+
+ #ATTENTION BUG with ticket #2551 not checked in unittest
+ bboxDom=dataInputsDom[0].getElementsByTagNameNS(self.wpsns,"BoundingBoxData")
+ #dimSet has to be identifical to LowerCorner/UpperCorner dim
+ dimSet=set(map(int,[item.getAttribute("dimensions") for item in bboxDom]) )
+ lowerSet=set([len(coord.split(" ")) for coord in [item.getElementsByTagNameNS(self.owsns,"LowerCorner")[0].childNodes[0].nodeValue for item in bboxDom]])
+ upperSet=set([len(coord.split(" ")) for coord in [item.getElementsByTagNameNS(self.owsns,"UpperCorner")[0].childNodes[0].nodeValue for item in bboxDom]])
+ self.assertEquals(len(dimSet.difference(lowerSet)),0) #0
+ self.assertEquals(len(dimSet.difference(upperSet)),0) #0
+
def _setFromEnv(self):
os.putenv("PYWPS_PROCESSES", os.path.join(pywpsPath,"tests","processes"))
os.environ["PYWPS_PROCESSES"] = os.path.join(pywpsPath,"tests","processes")
Modified: branches/pywps-3.2-soap/tests/processes/moreInOne.py
===================================================================
--- branches/pywps-3.2-soap/tests/processes/moreInOne.py 2011-07-07 14:44:19 UTC (rev 1169)
+++ branches/pywps-3.2-soap/tests/processes/moreInOne.py 2011-07-08 14:29:56 UTC (rev 1170)
@@ -8,11 +8,17 @@
statusSupported=True,
storeSupported=True)
- self.indata = self.addComplexInput(identifier="indata",title="Complex in",formats=[{"mimeType":"application/xml"}])
- self.outdata = self.addComplexOutput(identifier="outdata", title="Complex out",formats=[{"mimeType":"application/xml"}])
-
+ self.indata = self.addComplexInput(identifier="indata",title="Complex in",formats=[{"mimeType":"text/xml"},{"mimeType":"application/xml"}],minOccurs=0,maxOccurs=1024)
+ self.outdata = self.addComplexOutput(identifier="outdata", title="Complex out",formats=[{"mimeType":"text/xml"}])
+ self.outdata2 = self.addComplexOutput(identifier="outdata2", title="Complex out",formats=[{"mimeType":"application/xml"}])
def execute(self):
- self.outdata.setValue(self.indata.getValue())
+ #tmp=self.indata.getValue()
+ # import pydevd;pydevd.settrace()
+ #self.outdata.setValue(tmp)
+
+ #import pydevd;pydevd.settrace()
+ self.outdata.setValue(self.indata.getValue()[0])
+ self.outdata2.setValue(self.indata.getValue()[0])
Modified: branches/pywps-3.2-soap/tests/processes/tests.py
===================================================================
--- branches/pywps-3.2-soap/tests/processes/tests.py 2011-07-07 14:44:19 UTC (rev 1169)
+++ branches/pywps-3.2-soap/tests/processes/tests.py 2011-07-08 14:29:56 UTC (rev 1170)
@@ -178,3 +178,25 @@
def execute(self):
self.flag1Out.setValue(self.flag1In.getValue())
self.flag2Out.setValue(self.flag2In.getValue())
+
+class LineageReturn(WPSProcess):
+ """Lineage returning process, testing lineage with multiple inputs per identifier """
+ def __init__(self):
+ WPSProcess.__init__(self, identifier="lineagereturn",title="Dummy process with flags as InputOutput",storeSupported=False, statusSupported=False)
+ self.vectorIn = self.addComplexInput(identifier="vectorin",
+ title="Vector file",
+ formats =[{"mimeType":"application/xml"},{"mimeType":"text/xml"}],
+ minOccurs=1,
+ maxOccurs=1)
+ self.rasterIn = self.addComplexInput(identifier="rasterin",
+ title="Vector file",
+ formats =[{"mimeType":"image/png"},{"mimeType":"image/bmp"}],
+ minOccurs=1,
+ maxOccurs=1)
+ self.bboxin = self.addBBoxInput(identifier="bboxin",title="BBox in")
+ #self.vectorIn=self.addComplexInput(self,identifier="vectorin",title="vector input data",formats =[{"mimeType":"application/xml"},{"mimeType":"text/xml"}])
+ #self.rasterIn=self.addComplexInput(self,identifier="rasterin",title="raster input data",formats =[{"mimeType":"image/png"},{"mimeType":"image/bmp"}])
+ #self.literalOut=self.addLiteralOutput(self,identifier="literalout",title="dummy output")
+ def execute(self):
+ pass
+ #self.literalOut.setValue("dummy")
\ No newline at end of file
Added: branches/pywps-3.2-soap/tests/requests/wps_execute_request_lineage.xml
===================================================================
--- branches/pywps-3.2-soap/tests/requests/wps_execute_request_lineage.xml 2011-07-07 14:44:19 UTC (rev 1169)
+++ branches/pywps-3.2-soap/tests/requests/wps_execute_request_lineage.xml 2011-07-08 14:29:56 UTC (rev 1170)
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wps:Execute service="WPS" version="1.0.0"
+ xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1"
+ xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.opengis.net/wps/1.0.0/wpsExecute_request.xsd">
+ <ows:Identifier>lineagereturn</ows:Identifier>
+ <wps:DataInputs>
+ <wps:Input>
+ <ows:Identifier>vectorin</ows:Identifier>
+ <ows:Title>Input</ows:Title>
+ <wps:Data>
+ <wps:ComplexData mimeType="text/xml">
+ <ogr:FeatureCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://ogr.maptools.org/ singlePoint.xsd"
+ xmlns:ogr="http://ogr.maptools.org/" xmlns:gml="http://www.opengis.net/gml">
+ <gml:boundedBy>
+ <gml:Box>
+ <gml:coord>
+ <gml:X>348757.095296754</gml:X>
+ <gml:Y>239942.9447343307</gml:Y>
+ </gml:coord>
+ <gml:coord>
+ <gml:X>348757.095296754</gml:X>
+ <gml:Y>239942.9447343307</gml:Y>
+ </gml:coord>
+ </gml:Box>
+ </gml:boundedBy>
+ <gml:featureMember>
+ <ogr:singlePoint fid="F0">
+ <ogr:geometryProperty>
+ <gml:Point>
+ <gml:coordinates>348757.095296754036099,239942.944734330725623,741.989222523751437</gml:coordinates>
+ </gml:Point>
+ </ogr:geometryProperty>
+ <ogr:cat>1</ogr:cat>
+ </ogr:singlePoint>
+ </gml:featureMember>
+ </ogr:FeatureCollection>
+ </wps:ComplexData>
+ </wps:Data>
+ </wps:Input>
+ <wps:Input>
+ <ows:Identifier>vectorin</ows:Identifier>
+ <ows:Title>Input</ows:Title>
+ <wps:Data>
+ <!-- different mimetype for testing -->
+ <wps:ComplexData mimeType="application/xml">
+ <ogr:FeatureCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://ogr.maptools.org/ singlePoint.xsd"
+ xmlns:ogr="http://ogr.maptools.org/" xmlns:gml="http://www.opengis.net/gml">
+ <gml:boundedBy>
+ <gml:Box>
+ <gml:coord>
+ <gml:X>348757.095296754</gml:X>
+ <gml:Y>239942.9447343307</gml:Y>
+ </gml:coord>
+ <gml:coord>
+ <gml:X>348757.095296754</gml:X>
+ <gml:Y>239942.9447343307</gml:Y>
+ </gml:coord>
+ </gml:Box>
+ </gml:boundedBy>
+ <gml:featureMember>
+ <ogr:singlePoint fid="F0">
+ <ogr:geometryProperty>
+ <gml:Point>
+ <gml:coordinates>348757.095296754036099,239942.944734330725623,741.989222523751437</gml:coordinates>
+ </gml:Point>
+ </ogr:geometryProperty>
+ <ogr:cat>1</ogr:cat>
+ </ogr:singlePoint>
+ </gml:featureMember>
+ </ogr:FeatureCollection>
+ </wps:ComplexData>
+ </wps:Data>
+ </wps:Input>
+ <wps:Input>
+ <ows:Identifier>rasterin</ows:Identifier>
+ <ows:Title>Input</ows:Title>
+ <wps:Data>
+ <wps:ComplexData mimeType="image/png">iVBORw0KGgoAAAANSUhEUgAAAA0AAAAGCAYAAAAYLBS/AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAK6wAACusBgosNWgAAAAd0SU1FB9sHBwkUGkfHt0UAAACgSURBVBhXVc+9DgFBFEDhWTTiJyIqYStRSVQalYK30HlGnVqppliFqCSIRgTBOTIFN/lm7uzMnTubhP9IWL5/PlXIR6jhiDN2OYY2JqjDAg+aGwP0sUEB7pfyDFNcUMYeTYzR8QC2qGIOLxta1IJxQy/mFhZxgF18thc2sHbRRYoFZrhiCZ+TxdncS79hpzse8CdPsMMqrpnCC08TwibhA3BzHkfz5rzlAAAAAElFTkSuQmCC</wps:ComplexData>
+ </wps:Data>
+ </wps:Input>
+ <wps:Input>
+ <ows:Identifier>rasterin</ows:Identifier>
+ <ows:Title>Input</ows:Title>
+ <wps:Data>
+ <wps:ComplexData mimeType="image/bmp">Qk3uAAAAAAAAAEYAAAA4AAAADQAAAAYAAAABABAAAwAAAKgAAADrCgAA6woAAAAAAAAAAAAAAPgAAOAHAAAfAAAAAAAAAAAAAAD//wAAAAD///////////////8AAP//AAAAAAAA//8AAAAAAAAAAP//AAAAAP///////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//wAAAAAAAAAAAAAAAP//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//wAAAAD//wAAAAAAAAAAAAAAAAAA////////AAD///////8AAAAAAAAAAAAAAAAAAA==</wps:ComplexData>
+ </wps:Data>
+ </wps:Input>
+ <wps:Input>
+ <ows:Identifier>bboxin</ows:Identifier>
+ <ows:Title>BBOx in</ows:Title>
+ <wps:Data>
+ <wps:BoundingBoxData ows:crs="urn:ogc:def:crs:EPSG:6.6:4326" ows:dimensions="2">
+ <ows:LowerCorner>-11 -12</ows:LowerCorner>
+ <ows:UpperCorner>13 14</ows:UpperCorner>
+ </wps:BoundingBoxData>
+ </wps:Data>
+ </wps:Input>
+ <wps:Input>
+ <ows:Identifier>bboxin</ows:Identifier>
+ <ows:Title>BBOx in</ows:Title>
+ <wps:Data>
+ <wps:BoundingBoxData ows:crs="urn:ogc:def:crs:EPSG:6.6:4326" ows:dimensions="2">
+ <ows:LowerCorner>-9 -3</ows:LowerCorner>
+ <ows:UpperCorner>11 13</ows:UpperCorner>
+ </wps:BoundingBoxData>
+ </wps:Data>
+ </wps:Input>
+ </wps:DataInputs>
+ <wps:ResponseForm>
+ <wps:ResponseDocument storeExecuteResponse="false" lineage="true" />
+ </wps:ResponseForm>
+</wps:Execute>
\ No newline at end of file
Added: branches/pywps-3.2-soap/tests/requests/wps_execute_request_reference_lineage.xml
===================================================================
--- branches/pywps-3.2-soap/tests/requests/wps_execute_request_reference_lineage.xml 2011-07-07 14:44:19 UTC (rev 1169)
+++ branches/pywps-3.2-soap/tests/requests/wps_execute_request_reference_lineage.xml 2011-07-08 14:29:56 UTC (rev 1170)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wps:Execute service="WPS" version="1.0.0"
+ xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1"
+ xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.opengis.net/wps/1.0.0/wpsExecute_request.xsd">
+ <ows:Identifier>lineagereturn</ows:Identifier>
+ <wps:DataInputs>
+ <wps:Input>
+ <ows:Identifier>vectorin</ows:Identifier>
+ <wps:Reference xlink:href="http://rsg.pml.ac.uk/wps/testdata/single_point.gml" />
+ </wps:Input>
+ <wps:Input>
+ <ows:Identifier>vectorin</ows:Identifier>
+ <ows:Title>Input</ows:Title>
+ <wps:Reference xlink:href="http://rsg.pml.ac.uk/wps/testdata/single_point.gml" />
+ </wps:Input>
+ <wps:Input>
+ <ows:Identifier>rasterin</ows:Identifier>
+ <ows:Title>Input</ows:Title>
+ <wps:Reference xlink:href="http://rsg.pml.ac.uk/wps/testdata/pywps_small.png.base64" />
+ </wps:Input>
+ <wps:Input>
+ <ows:Identifier>rasterin</ows:Identifier>
+ <ows:Title>Input</ows:Title>
+ <wps:Reference xlink:href="http://rsg.pml.ac.uk/wps/testdata/pywps_small.bmp.base64" />
+ </wps:Input>
+ <wps:Input>
+ <ows:Identifier>bboxin</ows:Identifier>
+ <ows:Title>BBOx in</ows:Title>
+ <wps:Data>
+ <wps:BoundingBoxData ows:crs="urn:ogc:def:crs:EPSG:6.6:4326" ows:dimensions="2">
+ <ows:LowerCorner>-9 -3</ows:LowerCorner>
+ <ows:UpperCorner>11 13</ows:UpperCorner>
+ </wps:BoundingBoxData>
+ </wps:Data>
+ </wps:Input>
+ </wps:DataInputs>
+ <wps:ResponseForm>
+ <wps:ResponseDocument storeExecuteResponse="false" lineage="true" />
+ </wps:ResponseForm>
+</wps:Execute>
\ No newline at end of file
More information about the Pywps-commits
mailing list