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]

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

Parameters:
  • workdir – working directory, to save temporal file objects in
  • modeMODE validation mode
>>> # 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)

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=[], 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, GEOTIFF, WCS, WCS100, WCS110, WCS20, WFS, WFS100, WFS110, WFS20, WMS, WMS130, WMS110, WMS100, TEXT, 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 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='', 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.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.response.WPSResponse(wps_request, uuid=None)[source]
status

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

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.response.status.STATUS) – process status - user should usually ommit this parameter

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.