PyWPS API Doc

Process

class pywps.Process(handler, identifier, title, abstract='', keywords=[], profile=[], metadata=[], inputs=[], outputs=[], version='None', store_supported=False, status_supported=False, grass_location=None)[source]
Parameters:
  • handler – A callable that gets invoked for each incoming request. It should accept a single pywps.app.WPSRequest argument and return a pywps.app.WPSResponse object.
  • identifier (string) – Name of this process.
  • title (string) – Human readable title of process.
  • abstract (string) – Brief narrative description of the process.
  • keywords (list) – Keywords that characterize a process.
  • inputs – List of inputs accepted by this process. They should be LiteralInput and ComplexInput and BoundingBoxInput objects.
  • outputs – List of outputs returned by this process. They should be LiteralOutput and ComplexOutput and BoundingBoxOutput objects.
  • metadata – List of metadata advertised by this process. They should be pywps.app.Common.Metadata objects.

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]

Base IO handling class subclassed by specialized versions: FileHandler, UrlHandler, DataHandler, etc.

If the specialized handling class is not known when the object is created, instantiate the object with IOHandler. The first time the file, url or data attribute is set, the associated subclass will be automatically registered. Once set, the specialized subclass cannot be switched.

Parameters:
  • workdir – working directory, to save temporal file objects in.
  • modeMODE validation mode.
file : str
Filename on the local disk.
url : str
Link to an online resource.
stream : FileIO
A readable object.
data : object
A native python object (integer, string, float, etc)
base64 : str
A base 64 encoding of the data.
>>> # setting up
>>> import os
>>> from io import RawIOBase
>>> from io import FileIO
>>>
>>> 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 isinstance(ioh_file, FileHandler
>>> assert ioh_file.file == fileobj.name
>>> assert isinstance(ioh_file.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 isinstance(ioh_stream, StreamHandler)
>>> assert open(ioh_stream.file).read() == ioh_file.stream.read()
>>> assert isinstance(ioh_stream.stream, RawIOBase)

LiteralData

class pywps.LiteralInput(identifier, title, data_type='integer', abstract='', keywords=[], metadata=[], uoms=None, min_occurs=1, max_occurs=1, mode=1, allowed_values=<class 'pywps.inout.literaltypes.AnyValue'>, default=None, default_type=3)[source]
Parameters:
  • identifier (str) – The name of this input.
  • title (str) – Title of the input
  • data_type (pywps.inout.literaltypes.LITERAL_DATA_TYPES) – data type
  • abstract (str) – Input abstract
  • keywords (list) – Keywords that characterize this input.
  • metadata (list) – TODO
  • uoms (str) – units
  • min_occurs (int) – minimum occurence
  • max_occurs (int) – maximum occurence
  • mode (pywps.validator.mode.MODE) – validation mode (none to strict)
  • allowed_values (pywps.inout.literaltypes.AnyValue) – or pywps.inout.literaltypes.AllowedValue object
  • metadata – List of metadata advertised by this process. They should be pywps.app.Common.Metadata objects.
class pywps.LiteralOutput(identifier, title, data_type='string', abstract='', keywords=[], metadata=[], uoms=None, 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='', keywords=[], metadata=[], min_occurs=1, max_occurs=1, mode=0, default=None, default_type=3)[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
  • data_format (pywps.inout.formats.Format) – default data format
  • abstract (str) – Input abstract
  • keywords (list) – Keywords that characterize this input.
  • metadata (list) – TODO
  • min_occurs (int) – minimum occurrence
  • max_occurs (int) – maximum occurrence
  • mode (pywps.validator.mode.MODE) – validation mode (none to strict)
class pywps.ComplexOutput(identifier, title, supported_formats=None, abstract='', keywords=[], 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, KML, KMZ, GEOTIFF, WCS, WCS100, WCS110, WCS20, WFS, WFS100, WFS110, WFS20, WMS, WMS130, WMS110, WMS100, TEXT, DODS, NETCDF, LAZ, LAS) 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 proper 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='', keywords=[], dimensions=2, metadata=[], min_occurs=1, max_occurs=1, mode=0, default=None, default_type=3)[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’])
  • keywords (list) – Keywords that characterize this input.
  • dimensions (int) – 2 or 3
  • metadata (list) – TODO
  • 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='', keywords=[], 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.response.status.WPS_STATUS

WPSStatus(UNKNOWN, ACCEPTED, STARTED, PAUSED, SUCCEEDED, FAILED) 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.response.WPSResponse(wps_request, uuid=None, version='1.0.0')[source]
status

Information about currently running process status pywps.response.status.STATUS

Processing

pywps.processing.Process(process, wps_request, wps_response)[source]

Factory method (looking like a class) to return the configured processing class.

Returns:instance of pywps.processing.Processing
class pywps.processing.Processing(process, wps_request, wps_response)[source]

Processing is an interface for running jobs.

class pywps.processing.Job(process, wps_request, wps_response)[source]

Job represents a processing job.

Refer Exceptions for their description.