How to use pywps - 10 common examples

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 ESGF / esgf-compute-wps / server / processes / test_process.py View on Github external
def __init__(self):
    """Process initialization"""
    # init process
    WPSProcess.__init__(self,
        identifier = os.path.split(__file__)[-1].split(".")[0],
        title="TESTit",
        version = 0.1,
        abstract = "Just testing basic functions, adding input, checking status, etc...",
        storeSupported = "true",
        statusSupported = "true",
        )
    self.valueIn = self.addLiteralInput(identifier = "val", type=types.IntType,title = "User Input Value", default = 6)
    self.timePauseIn = self.addLiteralInput(identifier = "pauseTime", type=types.FloatType,title = "User Value for Pause Time", default = 1.)
    self.numberPauseIn = self.addLiteralInput(identifier = "pauseNumber", type=types.IntType,title = "User Value for Number of Pauses", default = 3)
    self.pauseIn = self.addLiteralInput(identifier = "pause", type=bool,title = "User Input Value", default = True)
    self.textOut = self.addLiteralOutput(identifier="text", title="just some text")
  def execute(self):
github geopython / pywps / tests / test_execute.py View on Github external
def create_greeter():
    def greeter(request, response):
        name = request.inputs['name'][0].data
        assert type(name) is text_type
        response.outputs['message'].data = "Hello %s!" % name
        return response

    return Process(handler=greeter,
                   identifier='greeter',
                   title='Greeter',
                   inputs=[LiteralInput('name', 'Input name', data_type='string')],
                   outputs=[LiteralOutput('message', 'Output message', data_type='string')])
github geopython / pywps / tests / test_execute.py View on Github external
with nc.Dataset(url) as D:
            response.outputs['conventions'].data = D.Conventions

        response.outputs['outdods'].url = url
        response.outputs['ncraw'].file = os.path.join(DATA_DIR, 'netcdf', 'time.nc')
        response.outputs['ncraw'].data_format = FORMATS.NETCDF
        return response

    return Process(handler=complex_proces,
                   identifier='my_opendap_process',
                   title='Opendap process',
                   inputs=[
                       ComplexInput(
                           'dods',
                           'Opendap input',
                           supported_formats=[Format('DODS'), Format('NETCDF')],
                           #   mode=MODE.STRICT
                       )
                   ],
                   outputs=[
                       LiteralOutput(
                           'conventions',
                           'NetCDF convention',
                       ),
                       ComplexOutput('outdods', 'Opendap output',
                                     supported_formats=[FORMATS.DODS, ],
                                     as_reference=True),
                       ComplexOutput('ncraw', 'NetCDF raw data output',
                                     supported_formats=[FORMATS.NETCDF, ],
                                     as_reference=False)
                   ])
github geopython / pywps / tests / test_ows.py View on Github external
if grass.mapcalc("$output = $input + $value", output="output", input="input", value=1.0) != 0:
            raise NoApplicableCode("Could not set GRASS region.")

        # Export the result
        out = "./output.tif"
        if grass.run_command("r.out.gdal", input="output", type="Float32", output=out) != 0:
            raise NoApplicableCode("Could not export result from GRASS.")

        response.outputs['output'] = out
        return response

    return Process(handler=sum_one,
                   identifier='sum_one',
                   title='Process Sum One',
                   inputs=[ComplexInput('input', [Format('image/img')])],
                   outputs=[ComplexOutput('output', [Format('image/tiff')])])
github geopython / pywps / tests / test_execute.py View on Github external
return response

    frmt = Format(mime_type='application/gml', extension=".gml")  # this is unknown mimetype

    return Process(handler=complex_proces,
                   identifier='my_complex_process',
                   title='Complex process',
                   inputs=[
                       ComplexInput(
                           'complex',
                           'Complex input',
                           default="DEFAULT COMPLEX DATA",
                           supported_formats=[frmt])
                   ],
                   outputs=[
                       ComplexOutput(
                           'complex',
                           'Complex output',
                           supported_formats=[frmt])
                   ])
github geopython / pywps / tests / test_inout.py View on Github external
def make_literal_input(self):
        literal = inout.inputs.LiteralInput(
            identifier="complexinput",
            title='MyComplex',
            data_type='string',
            workdir=self.tmp_dir,
            abstract="some description",
            keywords=['kw1', 'kw2'],
            metadata=[Metadata("special data")],
            uoms=['metre', 'unity'],
            min_occurs=2,
            max_occurs=5,
            mode=MODE.STRICT,
            allowed_values=[AllowedValue(value='something'), AllowedValue(value='something else'), AnyValue()],
            default="something else",
            default_type=SOURCE_TYPE.DATA,
        )
        literal.data = 'something'
        literal.uom = UOM('unity')
        literal.as_reference = False
        return literal
github geopython / pywps / pywps / tests.py View on Github external
[Format('application/json'), Format('application/x-netcdf')],
                               abstract="Complex input abstract.", ),
                  BoundingBoxInput('bb_input', 'BoundingBox input title', ['EPSG:4326', ],
                                   metadata=[Metadata('EPSG.io', 'http://epsg.io/'), ]),
                  ]
        outputs = [LiteralOutput('literal_output', 'Literal output title', 'boolean', 'Boolean output abstract.',),
                   ComplexOutput('complex_output', 'Complex output', [Format('text/plain'), ], ),
                   BoundingBoxOutput('bb_output', 'BoundingBox output title', ['EPSG:4326', ])]

        super(DocExampleProcess, self).__init__(
            self._handler,
            identifier='doc_example_process_identifier',
            title="Process title",
            abstract="Multiline process abstract.",
            version="4.0",
            metadata=[Metadata('PyWPS docs', 'http://pywps.org'),
                      Metadata('NumPy docstring conventions',
                               'https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt')],
            inputs=inputs,
            outputs=outputs,
        )
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)