[Pywps-commits] r1110 - in trunk: pywps/Process pywps/Wps/Execute tests tests/processes
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Feb 1 16:25:00 CET 2011
Author: jesus
Date: 2011-02-01 16:24:56 +0100 (Tue, 01 Feb 2011)
New Revision: 1110
Modified:
trunk/pywps/Process/InAndOutputs.py
trunk/pywps/Process/__init__.py
trunk/pywps/Wps/Execute/__init__.py
trunk/tests/perform_requests.py
trunk/tests/processes/tests.py
Log:
NEW checkMimeType implementation. Loose implementation. self.format always filled except when no formats list is given. Logging and comparison of mimeTypeInput/mimeTypesMagic. New functions: ComplexInput.checkMimeTypeIn,ComplexOutputMimeTypeIn and Execute.checkMimeTypeOutput
Modified: trunk/pywps/Process/InAndOutputs.py
===================================================================
--- trunk/pywps/Process/InAndOutputs.py 2011-02-01 15:22:44 UTC (rev 1109)
+++ trunk/pywps/Process/InAndOutputs.py 2011-02-01 15:24:56 UTC (rev 1110)
@@ -1,8 +1,8 @@
"""
Inputs and outputs of OGC WPS Processes
"""
-# Author: Jachym Cepicky
-# http://les-ejk.cz
+# Author: Jachym Cepicky
+# http://les-ejk.cz
# Lince:
#
# Web Processing Service implementation
@@ -116,7 +116,6 @@
def _setValueWithOccurence(self,oldValues, newValue):
"""Check min and max occurrence and set this.value"""
-
if self.maxOccurs > 1:
if not oldValues:
oldValues = [newValue]
@@ -335,15 +334,16 @@
"""
maxFileSize = None
formats = None
- format = {}
+ format = None
def __init__(self,identifier,title,abstract=None,
metadata=[],minOccurs=1,maxOccurs=1,
- maxmegabites=5,formats=[{"mimeType":"text/xml"}]):
+ maxmegabites=5,formats=[{"mimeType":None}]):
"""Class constructor"""
Input.__init__(self,identifier,title,abstract=abstract,
metadata=[],minOccurs=minOccurs,maxOccurs=maxOccurs,type="ComplexValue")
+
if maxmegabites:
self.maxFileSize = float(maxmegabites)*1024*1024
else:
@@ -380,16 +380,40 @@
if not input.has_key("type") and\
(input["value"].find("http://") == 0 or input["value"].find("http%3A%2F%2F") == 0):
input["asReference"] = True
-
+
#self.value = input["value"]
# download data
- if input.has_key("asReference") and input["asReference"] == True:
- import sys
+
+ if input.has_key("asReference") and input["asReference"] == True:
self.downloadData(input["value"])
else:
self.storeData(input["value"])
return
+
+ def setMimeType(self,input):
+ """Sets the MimeType from input before going to setValue() this allows
+ for some self.format to be filled febore base64 decoding. URL inputs done have an input[], since they are just URLs.
+ There is the need a mimeType implementation from downloaded objects"""
+ # if HTTP GET was performed, the type does not have to be set
+ #copy from setvalue
+ if not input.has_key("type") and (input["value"].find("http://") == 0 or input["value"].find("http%3A%2F%2F") == 0):
+ #jmd this needs to be changed, the self.format sould be set from the download stream
+ #For now
+ self.format["mimetype"]=None
+ self.format["schema"]=None
+ self.format["encoding"]=None
+ else:
+ try:
+ self.format["mimetype"]=input["mimetype"]
+ self.format["schema"]=input["schema"]
+ self.format["encoding"]=input["encoding"]
+
+ except Exception,e:
+ logging.debug("Passing mimeType/schema/encoding to process object failed,Exception in next line")
+ logging.debug(e)
+
+
def storeData(self,data):
"""Store data from given file. Not bigger, then
@@ -406,14 +430,16 @@
try:
fout=open(outputName,'wb')
except IOError, what:
- self.onProblem("NoApplicableCode","Could not open file for writing")
-
+ self.onProblem("NoApplicableCode","Could not open file for writing")
# NOTE: the filesize should be already checked in pywps/Post.py,
# while getting the input XML file
fout.write(data)
fout.close()
- if (self.formats[0]["mimeType"].lower().split("/")[0] != "text" and self.formats[0]["mimeType"].lower() != "application/xml"):
+ self.checkMimeTypeIn(fout.name)
+
+ #self.format already set
+ if (self.format["mimetype"].lower().split("/")[0] != "text" and self.format["mimetype"].lower() != "application/xml"):
# convert it to binary using base64
rename(fout.name,fout.name+".base64")
try:
@@ -422,11 +448,15 @@
self.onProblem("NoApplicableCode", "Could not convert text input to binary using base64 encoding.")
finally:
os.remove(fout.name+".base64")
-
-
- #MimeType can be checked, since we no longer have a base64 binary content
- self.checkMimeType(fout.name)
-
+ #Checking what is actu
+ try:
+ mimeTypeMagic=self.ms.file(fileName).split(';')[0]
+ if self.format["mimetype"]!=mimeTypeMagic:
+ logging.debug("ComplexDataInput defines mimeType %s (default set) but libMagic detects %s" % (str(self.format["mimetype"]),mimeTypeMagic))
+ except:
+ pass
+
+
resp = self._setValueWithOccurence(self.value, outputName)
if resp:
return resp
@@ -490,10 +520,7 @@
str(self.maxFileSize/1024/1024)+" MB for input "+
url)
fout.close()
-
- # check the mimetypes
- self.checkMimeType(fout.name)
-
+ self.checkMimeTypeIn(fout.name)
resp = self._setValueWithOccurence(self.value, outputName)
if resp:
return resp
@@ -508,29 +535,40 @@
"""
pass
- def checkMimeType(self,fileName):
+ def checkMimeTypeIn(self,fileName):
+
"""Check, if the given mimetype is in self.formats
-
+ checkMimeType is done after process.format is set by parsing user's content.
+ 1) if process.format[mimetype] has content it will be check in formats
+ 2) if process.format[mimetype]-->None assume process.format as first in list
+ a) no exceptions should be risen
+ 3) If formats dict is empty then there is nothing that can be done, and self.format=None
:param fileName:
:param mimeType:
"""
+
- #magic can't determine if a string is plain text of text/xml
- #so we can only validate the content for text
+
#Note: magic output something like: 'image/tiff; charset=binary' we only need the typeContent
- mimeType=self.ms.file(fileName).split(';')[0]
- if mimeType.find("text")==-1: # no text or xml
- for format in self.formats:
-
- if mimeType in format["mimeType"]:
- self.format = format
- return
-
- if self.format == {}:
- #InvalidParameterValue requires a simple locator and doesn't support a verbose output
- logging.debug("%s has mimeType %s according to magic. MimeType not valid according to process" % (str(self.identifier),str(mimeType)))
- self.onProblem("InvalidParameterValue",self.identifier)
-
+ if (self.format["mimetype"] is None) or (self.format["mimetype"]==""):
+ #No mimeType let's set it from default
+ logging.debug("Missing ComplexDataInput mimeType, adopting default mimeType (first in formats list)")
+ self.format["mimetype"]=self.formats[0]["mimeType"]
+
+ #checking format with libmagic
+ #--> new funcion aget base64 change
+ #mimeTypeMagic=self.ms.file(fileName).split(';')[0]
+ #if self.format["mimetype"]!=mimeTypeMagic:
+ # logging.debug("ComplexDataInput defines mimeType %s (default set) but libMagic detects %s" % (str(self.format["mimetype"]),mimeTypeMagic))
+ else:
+ #Checking is mimeType is in the acceptable formats
+ if self.format["mimetype"] not in [dic["mimeType"] for dic in self.formats]:
+ #ATTENTION: False positive if dictionary is not set in process/empty
+ if (len(self.formats)==1) and (type(self.formats[0]["mimeType"])==types.NoneType):
+ logging.debug("Process without mimetype list, cant check if ComplexDataInput mimtype is correct or not")
+ else:
+ logging.debug("ComplexDataInputXML defines mimeType %s which is not in process %s formats list" % (str(self.format["mimetype"]),str(self.identifier)))
+ self.onProblem("InvalidParameterValue",self.identifier)
def onMaxFileSizeExceeded(self, what):
@@ -856,11 +894,10 @@
does not work, try to adjust them manualy.
Unlike ComplexInput, the check for mimeType is done in Execute during
- output consolidation.
-
+ output consolidation.
"""
formats = None
- format = {}
+ format = {"mimetype":None,"encoding":None,"schema":None}
projection = None
bbox = None
width = None
@@ -868,7 +905,7 @@
useMapscript = False
def __init__(self,identifier,title,abstract=None,
- metadata=[], formats=[{"mimeType":"text/xml"}],
+ metadata=[], formats=[{"mimeType":None}],
asReference=False, projection=None, bbox=None, useMapscript
= False):
"""Class constructor"""
@@ -885,14 +922,13 @@
format["encoding"] = None
if not "schema" in format.keys():
format["schema"] = None
-
+
self.formats = formats
self.format={}
-
+
self.projection = projection
self.bbox = bbox
self.useMapscript = useMapscript
-
try:
self.ms = magic.open(magic.MAGIC_MIME)
self.ms.load()
@@ -911,8 +947,7 @@
#Note: cStringIO and StringIO are totally messed up, StringIO is type instance, cString is type cStringIO.StringO
#Better to also use __class__.__name__ to be certain what is is
# StringIO => StringIO but cStringIO => StringO
-
- if type(value) == types.StringType or types.UnicodeType:
+ if type(value) == types.StringType or type(value)==types.UnicodeType:
self.value = value
elif type(value) == types.FileType:
self.value = value.name
@@ -930,8 +965,39 @@
else:
raise Exception("Output type '%s' of '%s' output not known, not FileName, File or (c)StringIO object" %\
(type(value),self.identifier))
+
+
+
+ def checkMimeTypeIn(self):
+ #Checking the mimeType
+ #0) check if format has mimetype key, if input request has no mimeType then the key will be missing
+ #1) If missing mimeType, pick the default one from list
+ #2) check if mimeType is in the output.formats list, if not raise exception
+ #3) if no mimeType and no outputs.formats then do nothin
+ if (self.format["mimetype"] is None) or (self.format["mimetype"]==""):
+ logging.debug("Missing ComplexDataOutput mimeType in %s, adopting default mimeType %s (first in formats list)" % (self.identifier,self.formats[0]["mimeType"]))
+ self.format["mimetype"]=self.formats[0]["mimeType"]
+
+ else:
+ #Checking is mimeType is in the acceptable formats
+ if self.format["mimetype"] not in [dic["mimeType"] for dic in self.formats]:
+ #ATTENTION: False positive if dictionary is not set in process/empty formats list
+ if (len(self.formats)==1) and (type(self.formats[0]["mimeType"])==types.NoneType):
+ logging.debug("Process without mimetype list, cant check if ComplexDataOutput mimtype is correct or not")
+ else:
+ logging.debug("ComplexDataOutputXML defines mimeType %s which is not in process %s formats list" % (str(self.format["mimetype"]),str(self.identifier)))
+ self.onProblem("InvalidParameterValue",self.identifier)
+
+
+ def onProblem(self,what, why):
+ """Empty method, called, when there was any problem with the input.
+ This method is replaced in Execute.consolidateInputs, basically output.onProblem = self.onOutputProblem
+ therefore Exception raise is implemented in Execute.onInputProblem()
+ :param what: Message with error description
+ :param why: Error code
+ """
+ pass
-
class BoundingBoxOutput(Output):
"""Bounding box ouput
Modified: trunk/pywps/Process/__init__.py
===================================================================
--- trunk/pywps/Process/__init__.py 2011-02-01 15:22:44 UTC (rev 1109)
+++ trunk/pywps/Process/__init__.py 2011-02-01 15:24:56 UTC (rev 1110)
@@ -376,7 +376,7 @@
def addComplexInput(self,identifier,title,abstract=None,
metadata=[],minOccurs=1,maxOccurs=1,
- formats=[{"mimeType":"text/xml"}],maxmegabites=5):
+ formats=[{"mimeType":None}],maxmegabites=5):
"""Add complex input to this process
:param identifier: input identifier
@@ -456,7 +456,7 @@
# --------------------------------------------------------------------
def addComplexOutput(self,identifier,title,abstract=None,
- metadata=[],formats=[{"mimeType":"text/xml"}],
+ metadata=[],formats=[{"mimeType":None}],
useMapscript=False):
"""Add complex output to this process
Modified: trunk/pywps/Wps/Execute/__init__.py
===================================================================
--- trunk/pywps/Wps/Execute/__init__.py 2011-02-01 15:22:44 UTC (rev 1109)
+++ trunk/pywps/Wps/Execute/__init__.py 2011-02-01 15:24:56 UTC (rev 1110)
@@ -5,8 +5,8 @@
"""
-# Author: Jachym Cepicky
-# http://les-ejk.cz
+# Author: Jachym Cepicky
+# http://les-ejk.cz
# jachym at les-ejk dot cz
# License:
#
@@ -299,7 +299,6 @@
# FIXME: forking is always required, unless we find some better
# solution
forkingRequired = True
-
if forkingRequired:
try:
# this is the parent process
@@ -327,13 +326,12 @@
# init environment variable
self.initEnv()
-
+
# download and consolidate data
self.consolidateInputs()
-
+
# set output data attributes defined in the request
self.consolidateOutputs()
-
# Execute
self.executeProcess()
@@ -368,7 +366,7 @@
if not self.rawDataOutput:
# fill outputs
self.processOutputs()
-
+
if self.umn:
self.umn.save()
@@ -453,10 +451,9 @@
(identifier, self.process.identifier))
input = self.process.inputs[identifier]
-
+
# exceptions handler
input.onProblem = self.onInputProblem
-
# maximum input file size must not be greater, than the one,
# defined in the global config file
if input.type == "ComplexValue":
@@ -467,6 +464,12 @@
if self.wps.inputs["datainputs"]:
for inp in self.wps.inputs["datainputs"]:
if unicode(inp["identifier"]) == unicode(identifier):
+ #In complexValue trying to set the mimeType from user definition
+ # --> cant be here
+ if input.type == "ComplexValue":
+ input.setMimeType(inp)
+
+ #Passing value/content
resp = input.setValue(inp)
if resp:
self.cleanEnv()
@@ -476,8 +479,8 @@
# make sure, all inputs do have values
for identifier in self.process.inputs:
+
input = self.process.inputs[identifier]
-
if input.getValue() == None and input.minOccurs > 0:
self.cleanEnv()
raise pywps.MissingParameterValue(identifier)
@@ -499,29 +502,46 @@
"asReference" in dir(poutput):
poutput.asReference = respOut["asreference"]
- # mimetype
+ #jmdj mimetype and not mimeType
if respOut.has_key("mimetype") and \
"format" in dir(poutput):
if respOut["mimetype"] != '':
- poutput.format["mimeType"] = respOut["mimetype"]
+ poutput.format["mimetype"] = respOut["mimetype"]
# schema
if respOut.has_key("schema") and \
"format" in dir(poutput):
if respOut["schema"] != '':
poutput.format["schema"] = respOut["schema"]
-
+
# encoding
if respOut.has_key("encoding") and \
"format" in dir(poutput):
if respOut["encoding"] != '':
poutput.format["encoding"] = respOut["encoding"]
-
+
# uom
if respOut.has_key("uom") and \
"uom" in dir(poutput):
if respOut["uom"] != '':
poutput.uom = respOut["uom"]
+
+ #Even if the document response is not set
+ #self.format has to be created and filled
+ #Checking/resetting mimetype
+ #poutput --> ComplexOutputObject
+ for identifier in self.process.outputs:
+
+ poutput = self.process.outputs[identifier]
+ if poutput.type == "ComplexValue":
+
+ poutput.format["mimetype"]=None
+ poutput.format["schema"]=None
+ poutput.format["encoding"]=None
+ poutput.checkMimeTypeIn()
+
+
+
def onInputProblem(self,what,why):
"""This method is used for rewriting onProblem method of each input
@@ -542,12 +562,22 @@
self.cleanEnv()
raise exception(why)
- def onOutputProblem(self,identifier,mimeType):
- """This method logs the existance of problens in the complexData output mimeType
+ def onOutputProblem(self,what,why):
+ """This method logs the existance of problens in the complexData mainly (output mimeType?)
:param what: locator of the problem
:param why: possible reason of the problem
"""
- pywps.debug("Incorrect mimetype in %s. Found mimeType:%s" % (identifier,mimeType))
+ exception = None
+
+ if what == "FileSizeExceeded":
+ exception = pywps.FileSizeExceeded
+ elif what == "NoApplicableCode":
+ exception = pywps.NoApplicableCode
+ elif what == "InvalidParameterValue":
+ exception = pywps.InvalidParameterValue
+
+ self.cleanEnv()
+ raise exception(why)
def executeProcess(self):
@@ -725,15 +755,17 @@
"""
# encode the input file, if it has non-text mimetype
- if input.format["mimeType"].find("text") < 0:
+ 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["encoding"] = input.format["encoding"]
- complexInput["mimetype"] = input.format["mimeType"]
+ complexInput["mimetype"] = input.format["mimetype"]
complexInput["schema"] = input.format["schema"]
return complexInput
@@ -748,7 +780,7 @@
if wpsInput.has_key("method"):
method = wpsInput["method"]
complexInput["method"] = method
- complexInput["mimeType"] = processInput.format["mimeType"]
+ complexInput["mimeType"] = processInput.format["mimetype"]
complexInput["encoding"] = processInput.format["encoding"]
if wpsInput.has_key("header") and wpsInput["header"]:
complexInput["header"] = 1
@@ -776,10 +808,9 @@
output XML document.
"""
templateOutputs = []
+ outputsRequested=self.getRequestedOutputs()
- outputsRequested=self.getRequestedOutputs()
for identifier in outputsRequested:
- #for identifier in self.process.outputs.keys():
templateOutput = {}
output = self.process.outputs[identifier]
@@ -813,11 +844,12 @@
def _lineageComplexOutput(self, output, complexOutput):
- self.checkMimeType(output)
- complexOutput["mimetype"] = output.format["mimeType"]
+ #Checks for the correct output and logs
+ self.checkMimeTypeOutput(output)
+ complexOutput["mimeType"] = output.format["mimetype"]
complexOutput["encoding"] = output.format["encoding"]
complexOutput["schema"] = output.format["schema"]
-
+
return complexOutput
def _lineageBBoxOutput(self, output, bboxOutput):
@@ -844,16 +876,18 @@
if outputsRequested==[]:
outputsRequested=self.process.outputs.keys()
return outputsRequested
-
-
+
+
+
def processOutputs(self):
"""Fill <ProcessOutputs> part in the output XML document
This method is called if, self.status == ProcessSucceeded
"""
templateOutputs = []
+ outputsRequested=self.getRequestedOutputs()
- outputsRequested=self.getRequestedOutputs()
+
for identifier in outputsRequested:
#for identifier in self.process.outputs.keys():
try:
@@ -898,17 +932,20 @@
def _complexOutput(self, output, complexOutput):
- self.checkMimeType(output)
-
- complexOutput["mimeType"] = output.format["mimeType"]
+ #Checks for the correct output and logs
+ self.checkMimeTypeOutput(output)
+ #In complexOutput the variable is mimeType
+ complexOutput["mimeType"] = output.format["mimetype"]
complexOutput["encoding"] = output.format["encoding"]
complexOutput["schema"] = output.format["schema"]
-
+
+ if output.format["mimetype"] is not None:
# CDATA section in output
- if output.format["mimeType"].find("text") < 0:
+ #attention to application/xml
+ if output.format["mimetype"].find("text") < 0 and output.format["mimetype"].find("xml")<0:
#complexOutput["cdata"] = 1
- os.rename(output.value, output.value+".binary")
- base64.encode(open(output.value+".binary"),open(output.value,"w"))
+ os.rename(output.value, output.value+".binary")
+ base64.encode(open(output.value+".binary"),open(output.value,"w"))
# set output value
@@ -916,10 +953,15 @@
# remove <?xml version= ... part from beginning of some xml
# documents
- if output.format["mimeType"].find("xml") > -1:
- beginXml = complexOutput["complexdata"].split("\n")[0]
- if beginXml.find("<?xml ") > -1:
- complexOutput["complexdata"] = complexOutput["complexdata"].replace(beginXml+"\n","")
+ #Better <?xml search due to problems with \n
+ if output.format["mimetype"] is not None:
+ if output.format["mimetype"].find("xml") > -1:
+ beginXMLidx=complexOutput["complexdata"].find("?>")
+ #All <?xml..?> will be beginXMLidx + 2
+
+ #beginXml = complexOutput["complexdata"].split("\n")[0]
+ if beginXMLidx > -1:
+ complexOutput["complexdata"] = complexOutput["complexdata"].replace(complexOutput["complexdata"][:(beginXMLidx+2)],"")
return complexOutput
@@ -965,18 +1007,17 @@
# redefine the output
#Mapserver needs the format information, therefore checkMimeType has to be called before
- self.checkMimeType(output)
+ self.checkMimeTypeOutput(output)
if self.umn and output.useMapscript:
owsreference = self.umn.getReference(output)
if owsreference:
templateOutput["reference"] = owsreference
+ templateOutput["mimeType"] = output.format["mimetype"]
+ templateOutput["schema"] = output.format["schema"]
+ templateOutput["encoding"]=output.format["encoding"]
-
- templateOutput["mimetype"] = output.format["mimeType"]
- templateOutput["schema"] = output.format["encoding"]
- templateOutput["encoding"] = output.format["schema"]
return templateOutput
def _samefile(self, src, dst):
@@ -991,52 +1032,26 @@
return (os.path.normcase(os.path.abspath(src)) ==
os.path.normcase(os.path.abspath(dst)))
- def checkMimeType(self,output):
+ def checkMimeTypeOutput(self,output):
"""
Checks the complexData output to determine if the mimeType is correct.
if mimeType is not in the list defined by the user then it will log it as an error, no further action will be taken
- Mainly used by: _asReferenceOutput,_complexOutput,lineageComplexOutput,_lineageComplexReference
- Note: checkMimeType will set the output's format from the first
+ Mainly used by: _asReferenceOutput,_complexOutput,_lineageComplexOutput,_lineageComplexReference
+ Note: checkMimeTypeIn will set the output's format from the first time
"""
- output.format=output.formats[0]
- mimeType=output.ms.file(output.value).split(';')[0]
- isCorrect=False
- if mimeType.find("text")==-1 and mimeType.find("application/xml")==-1: # no text or xml
- for format in output.formats:
- if mimeType in format["mimeType"]:
- output.format=format
- isCorrect=True
+ try: # problem with exceptions ?!
+ mimeType=output.ms.file(output.value).split(';')[0]
+
+ if (output.format["mimetype"] is None) or (output.format["mimetype"]==""):
+ output.format["mimetype"]=mimeType
+ logging.debug("Since there is absolutely no mimeType information for %s, using libmagic mimeType %s " % (output.identifier,mimeType))
+ else:
+ if (mimeType.lower()!=output.format["mimetype"].lower()):
+ logging.debug("ComplexOut %s has libMagic mimeType: %s but its format is %s" % (output.identifier,mimeType,output.format["mimetype"]))
+ except:
+ pass
- if isCorrect == False:
- self.onOutputProblem(output.identifier,mimeType)
-
-
- #If mimeType is not found in the output list, We will use the one checked by magic
- #output.format={"mimeType":mimeType,"encoding":None,"schema":None}
-
- #=======================================================================
- # else: #dealing with text or xml
- # if we have < > we assume XML other wise plan text
- # f = open(output.value, 'r+')
- # startString=f.read(5)
- # f.seek(-5,2)
- # endString=f.read(5)
- # import pydevd;pydevd.settrace()
- # if (("<" in startString) or ("<" in startString)) and ((">" in endString) or (">" in endString)):
- # #assuming text/xml
- # mimeType="text/xml"
- # import pydevd;pydevd.settrace()
- # for format in output.formats:
- # if mimeType in format["mimeType"]:
- # isCorrect=True
- # else:
- # assuming text/plain
- # self.onOutputProblem(output.identifier,mimeType)
- # mimeType="text/plain"
- # output.format={"mimeType":mimeType,"encoding":None,"schema":None}
- #=======================================================================
-
def makeSessionId(self):
""" Returns unique Execute session ID
@@ -1186,7 +1201,7 @@
elif output.type == "ComplexValue":
- self.checkMimeType(output)
+ #self.checkMimeTypeIn(output)
# copy the file to safe place
outName = os.path.basename(output.value)
outSuffix = os.path.splitext(outName)[1]
@@ -1197,5 +1212,5 @@
COPY(os.path.abspath(output.value), outFile)
#check
- self.contentType = output.format["mimeType"]
+ self.contentType = output.format["mimetype"]
self.response = open(outFile,"rb")
Modified: trunk/tests/perform_requests.py
===================================================================
--- trunk/tests/perform_requests.py 2011-02-01 15:22:44 UTC (rev 1109)
+++ trunk/tests/perform_requests.py 2011-02-01 15:24:56 UTC (rev 1110)
@@ -27,7 +27,8 @@
getcapabilitiesrequest = "service=wps&request=getcapabilities"
getdescribeprocessrequest = "service=wps&request=describeprocess&version=1.0.0&identifier=dummyprocess"
getexecuterequest = "service=wps&request=execute&version=1.0.0&identifier=dummyprocess&datainputs=[input1=20;input2=10]"
- wfsurl = "http://www2.dmsolutions.ca/cgi-bin/mswfs_gmap?version=1.0.0&request=getfeature&service=wfs&typename=park"
+ #wfsurl = "http://www2.dmsolutions.ca/cgi-bin/mswfs_gmap?version=1.0.0&request=getfeature&service=wfs&typename=park"
+ wfsurl = "http://rsg.pml.ac.uk/geoserver2/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=rsg:areas_pw&maxFeatures=1"
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"
@@ -145,6 +146,7 @@
self.assertEquals(getliteraldata[1].firstChild.nodeValue, "1.1")
self.assertEquals(getliteraldata[2].firstChild.nodeValue, "False")
self.assertEquals(getliteraldata[3].firstChild.nodeValue, "spam")
+
def testT07ParseExecuteComplexInput(self):
@@ -271,17 +273,17 @@
import tempfile
getpywps = pywps.Pywps(pywps.METHOD_GET)
- #With new ResponseDocument the outputs get by the same order as indicated in the responseDocument
+ #Outputs will be generated accordint to the order in responsedocument
inputs = getpywps.parseRequest("service=wps&version=1.0.0&request=execute&identifier=complexprocessows&datainputs=[rasterin=%s;vectorin=%s]&responsedocument=[vectorout=@asreference=true;rasterout=@asreference=true]" % (urllib.quote(self.wcsurl), urllib.quote(self.wfsurl)))
getpywps.performRequest()
xmldom = minidom.parseString(getpywps.response)
-
+
self.assertFalse(len(xmldom.getElementsByTagNameNS(self.wpsns,"ExceptionReport")), 0)
# try to get out the Reference elemengt
wfsurl = xmldom.getElementsByTagNameNS(self.wpsns,"Reference")[0].getAttribute("xlink:href")
wcsurl = xmldom.getElementsByTagNameNS(self.wpsns,"Reference")[1].getAttribute("xlink:href")
-
+
# test, if there are WFS and WCS request strings
self.assertTrue(wfsurl.find("WFS") > -1)
self.assertTrue(wcsurl.find("WCS") > -1)
@@ -309,6 +311,7 @@
#all outputs --> blank responseDocument
inputs = getpywps.parseRequest("service=wps&version=1.0.0&request=execute&identifier=complexprocess&datainputs=[rasterin=%s;vectorin=%s]&responsedocument=[]" % (urllib.quote(self.wcsurl), urllib.quote(self.wfsurl)))
getpywps.performRequest()
+
xmldom = minidom.parseString(getpywps.response)
self.assertEquals(len(xmldom.getElementsByTagNameNS(self.wpsns,"Output")),2)
@@ -325,6 +328,7 @@
#The response linage contains URLs with & that will crash the DOM parser
xmldom = minidom.parseString(postpywps.response.replace("&","%26"))
+
#1 OutputDefintions only and that is rasterout
outputDefNodes=xmldom.getElementsByTagNameNS(self.wpsns,"OutputDefinitions")
self.assertEquals(len(outputDefNodes),1)
Modified: trunk/tests/processes/tests.py
===================================================================
--- trunk/tests/processes/tests.py 2011-02-01 15:22:44 UTC (rev 1109)
+++ trunk/tests/processes/tests.py 2011-02-01 15:24:56 UTC (rev 1110)
@@ -76,7 +76,7 @@
self.rasterin = self.addComplexInput(identifier="rasterin",
title="Raster file",
- formats = [{"mimeType":"image/tiff"}])
+ formats = [{'mimeType': 'image/tiff'}, {'mimeType': 'image/geotiff'}, {'mimeType': 'application/geotiff'}, {'mimeType': 'application/x-geotiff'}, {'mimeType': 'image/png'}, {'mimeType': 'image/gif'}, {'mimeType': 'image/jpeg'}, {'mimeType': 'application/x-erdas-hfa'}, {'mimeType': 'application/netcdf'}, {'mimeType': 'application/x-netcdf'}])
self.pausein = self.addLiteralInput(identifier="pause",
title="Pause the process",
@@ -86,7 +86,7 @@
self.vectorout = self.addComplexOutput(identifier="vectorout",
title="Vector file",
- formats = [{"mimeType":"application/xml"}])
+ formats = [{"mimeType":"text/xml"}])
self.rasterout = self.addComplexOutput(identifier="rasterout",
title="Raster file",
formats = [{"mimeType":"image/tiff"}])
@@ -136,7 +136,6 @@
self.vectorout.setValue(self.vectorin.getValue())
self.rasterout.setValue(self.rasterin.getValue())
-
if self.pausein.getValue():
import time
for i in range(5):
More information about the Pywps-commits
mailing list