How to use the pywps.Pywps function in pywps

To help you get started, we’ve selected a few pywps examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github geopython / pywps / tests / benchmark.py View on Github external
def testDescribeProcessPOST(self):
        """DescribeProcess all POST"""
        postpywps = pywps.Pywps(pywps.METHOD_POST)
        getCapabilitiesRequestFile = open(os.path.join(pywpsPath,"tests","requests","wps_describeprocess_request_all.xml"))
        postinputs = postpywps.parseRequest(getCapabilitiesRequestFile)
        postpywps.performRequest(postinputs)
github geopython / pywps / tests / benchmark.py View on Github external
def testWSDL(self):
        """WSDL request"""
        getpywps = pywps.Pywps(pywps.METHOD_GET)
        inputs = getpywps.parseRequest(self.getWSDL)
        getpywps.performRequest(inputs)
github geopython / pywps / tests / soap_tests.py View on Github external
def testGetCapabilitiesRPC(self):
       """Testing a complete getCapabilities using SOAP1.1, using RPC"""
       #SUDS SOAP client  https://fedorahosted.org/suds/
       self._setFromEnv()
       postpywps=pywps.Pywps(pywps.METHOD_POST)
       getCapabilitiesRPC=open(os.path.join(pywpsPath,"tests","requests","wps_getcapabilities_request_SOAP11RPC.xml"))
       postpywps.parseRequest(getCapabilitiesRPC)
       postpywps.performRequest()
       xmldoc=minidom.parseString(postpywps.response)
       #no need to generate soap response, just testing to get the getCapabilities document
       self.assertTrue(xmldoc.getElementsByTagNameNS(self.wpsns,"Capabilities")>0)
       #using some alternative version number
       getCapabilitiesRPC.seek(0)
       doc=minidom.parse(getCapabilitiesRPC)
       doc.getElementsByTagNameNS(self.owsns,'Version')[0].firstChild.nodeValue="3.0.0"
       try:
           postpywps.parseRequest(StringIO.StringIO(doc.toxml()))
       #
       except Exception as e:
           self.assertTrue("VersionNegotiationFailed" in e.code)
github geopython / pywps / tests / benchmark.py View on Github external
def testGetCapabilitiesPOST(self):
        """GetCapabilities POST"""
        postpywps = pywps.Pywps(pywps.METHOD_POST)
        getCapabilitiesRequestFile = open(os.path.join(pywpsPath,"tests","requests","wps_getcapabilities_request.xml"))
        postinputs = postpywps.parseRequest(getCapabilitiesRequestFile)
        postpywps.performRequest(postinputs)
github geopython / pywps / tests / parser.py View on Github external
def testParseDescribeProcess(self):
        """Test if DescribeProcess request is parsed and if POST and GET
        methods are producing the same result"""
        
        getpywps = pywps.Pywps(pywps.METHOD_GET)
        postpywps = pywps.Pywps(pywps.METHOD_POST)
        getinputs = getpywps.parseRequest("service=wps&request=describeprocess&version=1.0.0&identifier=dummyprocess")
        describeProcessFile = open(os.path.join(pywpsPath,"tests","requests","wps_describeprocess_request_dummyprocess.xml"))
        postinputs = postpywps.parseRequest(describeProcessFile)

        self.assertEquals(getpywps.inputs["request"], "describeprocess")
        self.assertTrue("dummyprocess" in getpywps.inputs["identifier"])
        self.assertFalse("returner" in getpywps.inputs["identifier"])

        self.assertEquals(postpywps.inputs["request"], "describeprocess")
        self.assertTrue("dummyprocess" in postpywps.inputs["identifier"])
        self.assertFalse("returner" in postpywps.inputs["identifier"])

        self.assertEquals(getinputs, postinputs)
github geopython / pywps / tests / perform_requests.py View on Github external
def test15ParseExecuteResponseDocumentPOST(self):
        """Return a response document that only containts the requested ouputs, from an XML request 
        lineage output will also be checked
        """
        
        self._setFromEnv()
        postpywps = pywps.Pywps(pywps.METHOD_POST)
        executeRequestFile = open(os.path.join(pywpsPath,"tests","requests","wps_execute_request-complexinput-one-output-as-reference.xml"))
        postinputs = postpywps.parseRequest(executeRequestFile)
        postpywps.performRequest()
        #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)
        identifierNodes=outputDefNodes[0].getElementsByTagNameNS(self.owsns,"Identifier")
        self.assertEquals(identifierNodes[0].firstChild.nodeValue,"rasterout")
        
        #1 ProcessOutput only check that is rasterout
        processOutNodes=xmldom.getElementsByTagNameNS(self.wpsns,"ProcessOutputs")
        self.assertEquals(len(processOutNodes),1)
        identifierNodes=processOutNodes[0].getElementsByTagNameNS(self.owsns,"Identifier")
github geopython / pywps / tests / perform_requests.py View on Github external
def test25WFSComplexOutput(self):
        """Test if PyWPS can return a correct WFS service content with projs"""
       #XML being checked by GDAL will raise an error, the unttest wil still be ok
       #ERROR 4: `/var/www/html/wpsoutputs/vectorout-26317EUFxeb' not recognised as a supported file format. 
        #USE urllib.quote_lus
        #'urllib.quote_plus("http://rsg.pml.ac.uk/wps/testdata/single_point.gml")
        self._setFromEnv()
        import osgeo.ogr
        getpywps = pywps.Pywps(pywps.METHOD_GET)
        #Outputs will be generated accordint to the order in responsedocument
        inputs = getpywps.parseRequest("service=wps&version=1.0.0&request=execute&identifier=ogrbuffer&datainputs=[data=%s;size=0.1]&responsedocument=[buffer=@asreference=true]" % urllib.quote(self.simpleLine))
        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("href")
        print wfsurl
        #wcsurl = xmldom.getElementsByTagNameNS(self.wpsns,"Reference")[1].getAttribute("href")
        wfsurl=urllib.unquote(wfsurl)
        inSource=osgeo.ogr.Open(wfsurl)
        self.assertTrue(isinstance(inSource,osgeo.ogr.DataSource))
        inLayer=inSource.GetLayer()
        self.assertTrue(isinstance(inLayer,osgeo.ogr.Layer))
github geopython / pywps / tests / parser.py View on Github external
def testParseExecuteLiteralInput(self):
        """Test if Execute request is parsed, literal data inputs, including '@' in GET """
        
        #NOTE: Unittest changed after SVN: 1146 to check for the parsing of "@"
        
        getpywps = pywps.Pywps(pywps.METHOD_GET)
        postpywps = pywps.Pywps(pywps.METHOD_POST)
        executeRequestFile = open(os.path.join(pywpsPath,"tests","requests","wps_execute_request-literalinput.xml"))
        getinputs = getpywps.parseRequest("service=wps&version=1.0.0&request=execute&identifier=literalprocess&datainputs=[int=1;string=spam%40foo.com@mimetype=text/plain@xlink:href=http%3A//www.w3.org/TR/xmlschema-2/%23string;float=1.1]")
        postinputs = postpywps.parseRequest(executeRequestFile)

        self.assertEquals(getinputs["request"], "execute")
        self.assertTrue("literalprocess" in getinputs["identifier"])
        
        self.assertEquals(postinputs["request"], "execute")
        self.assertTrue("literalprocess" in postinputs["identifier"])

        #self.assertEquals(getinputs, postinputs)
        self.assertEquals(getinputs["datainputs"][0]["value"],postinputs["datainputs"][0]["value"])
        self.assertEquals(getinputs["datainputs"][1]["value"],postinputs["datainputs"][1]["value"])
        self.assertEquals(getinputs["datainputs"][2]["value"],postinputs["datainputs"][2]["value"])
        self.assertTrue(getinputs["datainputs"][0]["value"],1)
        self.assertTrue(getinputs["datainputs"][1]["value"],"spam%40foo.com")
github geopython / pywps / tests / perform_requests.py View on Github external
def testT11ParseExecuteComplexVectorAndRasterInputsAsReferenceOutpu(self):
        """Test, if pywps can store complex values as reference"""
        postpywps = pywps.Pywps(pywps.METHOD_POST)
        executeRequestFile = open(os.path.join(pywpsPath,"tests","requests","wps_execute_request-complexinput-output-as-reference.xml"))
        postinputs = postpywps.parseRequest(executeRequestFile)
  
        postpywps.performRequest()
github geopython / pywps / webservices / mod_python / wps.py View on Github external
if not inputQuery:
        err =  NoApplicableCode("No query string found.")
        pywps.response.response(err,req)
        return apache.OK

    # set PYWPS_CFG and PYWPS_PROCESSES environment variable, which can not
    # bee seen from mod_python
    env_vars = req.subprocess_env.copy()
    if env_vars.has_key("PYWPS_CFG"):
        os.environ["PYWPS_CFG"] = env_vars["PYWPS_CFG"]
    if env_vars.has_key("PYWPS_PROCESSES"):
        os.environ["PYWPS_PROCESSES"] = env_vars["PYWPS_PROCESSES"]

    # create the WPS object
    try:
        wps = pywps.Pywps(req.method)
        if wps.parseRequest(inputQuery):
            pywps.debug(wps.inputs)
            wps.performRequest()
            pywps.response.response(wps.response, req,
                    wps.parser.isSoap, self.wps.parser.isSoapExecute,contentType = wps.request.contentType)
            return apache.OK
    except WPSException,e:
        pywps.response.response(e, req) 
        return apache.OK
    except Exception, e:
        req.content_type = "text/plain"
        traceback.print_exc(file = req)
        return apache.OK