PyWPS API Doc

Process

class pywps.Process(handler, identifier, title, abstract='', profile=[], metadata=[], inputs=[], outputs=[], version='None', store_supported=False, status_supported=False, grass_location=None)[source]
Parameters:

Inputs and outputs

class pywps.validator.mode.MODE[source]

Validation mode enumeration

NONE = 0
SIMPLE = 1
STRICT = 2
VERYSTRICT = 3

Most of the inputs nad outputs are derived from the IOHandler class

class pywps.inout.basic.IOHandler(workdir=None, mode=0)[source]

Basic IO class. Provides functions, to accept input data in file, memory object and stream object and give them out in all three types

>>> # setting up
>>> import os
>>> from io import RawIOBase
>>> from io import FileIO
>>> import types
>>>
>>> ioh_file = IOHandler(workdir=tmp)
>>> assert isinstance(ioh_file, IOHandler)
>>>
>>> # Create test file input
>>> fileobj = open(os.path.join(tmp, 'myfile.txt'), 'w')
>>> fileobj.write('ASDF ASFADSF ASF ASF ASDF ASFASF')
>>> fileobj.close()
>>>
>>> # testing file object on input
>>> ioh_file.file = fileobj.name
>>> assert ioh_file.source_type == SOURCE_TYPE.FILE
>>> file = ioh_file.file
>>> stream = ioh_file.stream
>>>
>>> assert file == fileobj.name
>>> assert isinstance(stream, RawIOBase)
>>> # skipped assert isinstance(ioh_file.memory_object, POSH)
>>>
>>> # testing stream object on input
>>> ioh_stream = IOHandler(workdir=tmp)
>>> assert ioh_stream.workdir == tmp
>>> ioh_stream.stream = FileIO(fileobj.name,'r')
>>> assert ioh_stream.source_type == SOURCE_TYPE.STREAM
>>> file = ioh_stream.file
>>> stream = ioh_stream.stream
>>>
>>> assert open(file).read() == ioh_file.stream.read()
>>> assert isinstance(stream, RawIOBase)
>>> # skipped assert isinstance(ioh_stream.memory_object, POSH)
>>>
>>> # testing in memory object object on input
>>> # skipped ioh_mo = IOHandler(workdir=tmp)
>>> # skipped ioh_mo.memory_object = POSH
>>> # skipped assert ioh_mo.source_type == SOURCE_TYPE.MEMORY
>>> # skipped file = ioh_mo.file
>>> # skipped stream = ioh_mo.stream
>>> # skipped posh = ioh_mo.memory_object
>>> #
>>> # skipped assert open(file).read() == ioh_file.stream.read()
>>> # skipped assert isinstance(ioh_mo.stream, RawIOBase)
>>> # skipped assert isinstance(ioh_mo.memory_object, POSH)

LiteralData

class pywps.LiteralInput(identifier, title, data_type='integer', abstract='', metadata=[], uoms=None, default=None, min_occurs=1, max_occurs=1, mode=1, allowed_values=<class 'pywps.inout.literaltypes.AnyValue'>)[source]
Parameters:
class pywps.LiteralOutput(identifier, title, data_type='string', abstract='', metadata=[], uoms=[], mode=1)[source]
Parameters:
  • identifier – The name of this output.
  • title (str) – Title of the input
  • data_type (pywps.inout.literaltypes.LITERAL_DATA_TYPES) – data type
  • abstract (str) – Input abstract
  • uoms (str) – units
  • mode (pywps.validator.mode.MODE) – validation mode (none to strict)
  • metadata – List of metadata advertised by this process. They should be pywps.app.Common.Metadata objects.
class pywps.inout.literaltypes.AnyValue[source]

Any value for literal input

class pywps.inout.literaltypes.AllowedValue(allowed_type='value', value=None, minval=None, maxval=None, spacing=None, range_closure='closed')[source]

Allowed value parameters the values are evaluated in literal validator functions

Parameters:
  • allowed_type (pywps.validator.allowed_value.ALLOWEDVALUETYPE) – VALUE or RANGE
  • value – single value
  • minval – minimal value in case of Range
  • maxval – maximal value in case of Range
  • spacing – spacing in case of Range
  • range_closure (pywps.input.literaltypes.RANGECLOSURETYPE) –
pywps.inout.literaltypes.LITERAL_DATA_TYPES = ('float', 'boolean', 'integer', 'string', 'positiveInteger', 'anyURI', 'time', 'date', 'dateTime', 'scale', 'angle', 'nonNegativeInteger')

tuple() -> empty tuple tuple(iterable) -> tuple initialized from iterable’s items

If the argument is a tuple, the return value is the same object.

ComplexData

class pywps.ComplexInput(identifier, title, supported_formats, data_format=None, abstract='', metadata=[], min_occurs=1, max_occurs=1, mode=0)[source]

Complex data input

Parameters:
  • identifier (str) – The name of this input.
  • title (str) – Title of the input
  • supported_formats (pywps.inout.formats.Format) – List of supported formats
  • abstract (str) – Input abstract
  • metada (list) – TODO
  • min_occurs (int) – minimum occurence
  • max_occurs (int) – maximum occurence
  • mode (pywps.validator.mode.MODE) – validation mode (none to strict)
class pywps.ComplexOutput(identifier, title, supported_formats=None, abstract='', metadata=None, as_reference=False, mode=0)[source]
Parameters:
  • identifier – The name of this output.
  • title – Readable form of the output name.
  • supported_formats (pywps.inout.formats.Format) – List of supported formats. The first format in the list will be used as the default.
  • abstract (str) – Description of the output
  • mode (pywps.validator.mode.MODE) – validation mode (none to strict)
  • metadata – List of metadata advertised by this process. They should be pywps.app.Common.Metadata objects.
class pywps.Format(mime_type, schema=None, encoding=None, validate=<function emptyvalidator>, mode=1, extension=None)[source]

Input/output format specification

Predefined Formats are stored in pywps.inout.formats.FORMATS

Parameters:
  • mime_type (str) – mimetype definition
  • schema (str) – xml schema definition
  • encoding (str) – base64 or not
  • validate (function) – function, which will perform validation. e.g.
  • mode (number) – validation mode
  • extension (str) – file extension
pywps.inout.formats.FORMATS

FORMATS(GEOJSON, JSON, SHP, GML, GEOTIFF, WCS, WCS100, WCS110, WCS20, WFS, WFS100, WFS110, WFS20, WMS, WMS130, WMS110, WMS100, TEXT, NETCDF)

List of out of the box supported formats. User can add custom formats to the array.

pywps.validator.complexvalidator.validategml(data_input, mode)[source]

GML validation function

Parameters:

This function validates GML input based on given validation mode. Following happens, if mode parameter is given:

MODE.NONE
it will return always True
MODE.SIMPLE
the mimetype will be checked
MODE.STRICT
GDAL/OGR is used for getting the propper format.
MODE.VERYSTRICT
the lxml.etree is used along with given input schema and the GML file is properly validated against given schema.

BoundingBoxData

class pywps.BoundingBoxInput(identifier, title, crss, abstract='', dimensions=2, metadata=[], min_occurs=1, max_occurs=1, mode=0)[source]
Parameters:
  • identifier (string) – The name of this input.
  • title (string) – Human readable title
  • abstract (string) – Longer text description
  • crss – List of supported coordinate reference system (e.g. [‘EPSG:4326’])
  • dimensions (int) – 2 or 3
  • min_occurs (int) – how many times this input occurs
  • max_occurs (int) – how many times this input occurs
  • metadata – List of metadata advertised by this process. They should be pywps.app.Common.Metadata objects.
class pywps.BoundingBoxOutput(identifier, title, crss, abstract='', dimensions=2, metadata=[], min_occurs='1', max_occurs='1', as_reference=False, mode=0)[source]
Parameters:
  • identifier – The name of this input.
  • title (str) – Title of the input
  • abstract (str) – Input abstract
  • crss – List of supported coordinate reference system (e.g. [‘EPSG:4326’])
  • dimensions (int) – number of dimensions (2 or 3)
  • min_occurs (int) – minimum occurence
  • max_occurs (int) – maximum occurence
  • mode (pywps.validator.mode.MODE) – validation mode (none to strict)
  • metadata – List of metadata advertised by this process. They should be pywps.app.Common.Metadata objects.

Request and response objects

pywps.app.WPSResponse.STATUS

Status(ERROR_STATUS, NO_STATUS, STORE_STATUS, STORE_AND_UPDATE_STATUS, DONE_STATUS)

Process status information

class pywps.app.WPSRequest(http_request=None)[source]
operation

Type of operation requested by the client. Can be getcapabilities, describeprocess or execute.

http_request

Original Werkzeug HTTPRequest object.

inputs

A MultiDict object containing input values sent by the client.

check_accepted_versions(acceptedversions)[source]
Parameters:acceptedversions – string
check_and_set_language(language)[source]

set this.language

check_and_set_version(version)[source]

set this.version

json

Return JSON encoded representation of the request

class pywps.app.WPSResponse(process, wps_request, uuid)[source]
status

Information about currently running process status pywps.app.WPSResponse.STATUS

call_on_close(function)[source]

Custom implementation of call_on_close of werkzeug TODO: rewrite this using werkzeug’s tools

update_status(message=None, status_percentage=None, status=None, clean=True)[source]

Update status report of currently running process instance

Parameters:
  • message (str) – Message you need to share with the client
  • status_percentage (int) – Percent done (number betwen <0-100>)
  • status (pywps.app.WPSResponse.STATUS) – process status - user should usually ommit this parameter

Refer Exceptions for their description.