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, translations=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.

  • translations (dict[str,dict[str,str]]) – The first key is the RFC 4646 language code, and the nested mapping contains translated strings accessible by a string property. e.g. {“fr-CA”: {“title”: “Mon titre”, “abstract”: “Une description”}}

Exceptions you can raise in the process implementation to show a user-friendly error message.

class pywps.app.exceptions.ProcessError(msg=None, min_length=3, max_length=300, allowed_chars=None)[source]

pywps.app.exceptions.ProcessError is an Exception you can intentionally raise in a process to provide a user-friendly error message. The error message gets formatted (3<= message length <=300) and only alpha numeric characters and a few special characters are allowed.

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 that handle multple IO types

This class is created with NoneIOHandler that have no data inside. To initialise data you can set the file, url, data or stream attribute. If reset one of this attribute old data are lost and replaced by the new one.

Parameters
  • workdir – working directory, to save temporal file objects in.

  • modeMODE validation mode.

filestr

Filename on the local disk.

urlstr

Link to an online resource.

streamFileIO

A readable object.

dataobject

A native python object (integer, string, float, etc)

base64str

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 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 open(ioh_stream.file).read() == ioh_file.stream.read()
>>> assert isinstance(ioh_stream.stream, RawIOBase)

LiteralData

class pywps.LiteralInput(identifier, title=None, data_type=None, workdir=None, abstract='', keywords=[], metadata=[], uoms=None, min_occurs=1, max_occurs=1, mode=1, allowed_values=None, default=None, default_type=3, translations=None)[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

  • workdir (str) – working directory, to save temporary file objects in.

  • 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.

  • translations (dict[str,dict[str,str]]) – The first key is the RFC 4646 language code, and the nested mapping contains translated strings accessible by a string property. e.g. {“fr-CA”: {“title”: “Mon titre”, “abstract”: “Une description”}}

class pywps.LiteralOutput(identifier, title, data_type='string', abstract='', keywords=[], metadata=[], uoms=None, mode=1, translations=None)[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.

  • translations (dict[str,dict[str,str]]) – The first key is the RFC 4646 language code, and the nested mapping contains translated strings accessible by a string property. e.g. {“fr-CA”: {“title”: “Mon titre”, “abstract”: “Une description”}}

class pywps.inout.literaltypes.AnyValue[source]

Specifies that any value is allowed for this quantity.

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

List of all valid values and/or ranges of values for this quantity. 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) –

class pywps.inout.literaltypes.ValuesReference(reference=None, values_form=None)[source]

Reference to list of all valid values and/or ranges of values for this quantity. NOTE: Validation of values is not implemented.

Param

reference: URL from which this set of ranges and values can be retrieved

Param

values_form: Reference to a description of the mimetype, encoding, and schema used for this set of values and ranges.

pywps.inout.literaltypes.LITERAL_DATA_TYPES = ('float', 'boolean', 'integer', 'string', 'positiveInteger', 'anyURI', 'time', 'date', 'dateTime', 'scale', 'angle', 'nonNegativeInteger', None)

Built-in immutable sequence.

If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is 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=[], workdir=None, metadata=[], min_occurs=1, max_occurs=1, mode=0, default=None, default_type=3, translations=None)[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.

  • workdir (str) – working directory, to save temporary file objects in.

  • metadata (list) – TODO

  • min_occurs (int) – minimum occurrence

  • max_occurs (int) – maximum occurrence

  • mode (pywps.validator.mode.MODE) – validation mode (none to strict)

  • translations (dict[str,dict[str,str]]) – The first key is the RFC 4646 language code, and the nested mapping contains translated strings accessible by a string property. e.g. {“fr-CA”: {“title”: “Mon titre”, “abstract”: “Une description”}}

class pywps.ComplexOutput(identifier: str, title: str, supported_formats: Optional[Sequence[Union[str, pywps.inout.formats.Format]]] = None, data_format=None, abstract: str = '', keywords=[], workdir=None, metadata: Optional[Sequence[pywps.app.Common.Metadata]] = None, as_reference=False, mode: pywps.validator.mode.MODE = 0, translations: Optional[Dict[str, Dict[str, str]]] = None)[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.

  • translations (dict[str,dict[str,str]]) – The first key is the RFC 4646 language code, and the nested mapping contains translated strings accessible by a string property. e.g. {“fr-CA”: {“title”: “Mon titre”, “abstract”: “Une description”}}

class pywps.Format(mime_type, schema=None, encoding=None, validate=None, 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, GPX, METALINK, META4, KML, KMZ, GEOTIFF, WCS, WCS100, WCS110, WCS20, WFS, WFS100, WFS110, WFS20, WMS, WMS130, WMS110, WMS100, TEXT, DODS, NETCDF, NCML, LAZ, LAS, ZIP, XML, CSV)

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

Fiona 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=None, abstract='', keywords=[], dimensions=2, workdir=None, metadata=[], min_occurs=1, max_occurs=1, mode=0, default=None, default_type=3, translations=None)[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

  • workdir (str) – working directory, to save temporary file objects in.

  • 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.

  • translations (dict[str,dict[str,str]]) – The first key is the RFC 4646 language code, and the nested mapping contains translated strings accessible by a string property. e.g. {“fr-CA”: {“title”: “Mon titre”, “abstract”: “Une description”}}

class pywps.BoundingBoxOutput(identifier, title, crss, abstract='', keywords=[], dimensions=2, metadata=[], min_occurs='1', max_occurs='1', as_reference=False, mode=0, translations=None)[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.

  • translations (dict[str,dict[str,str]]) – The first key is the RFC 4646 language code, and the nested mapping contains translated strings accessible by a string property. e.g. {“fr-CA”: {“title”: “Mon titre”, “abstract”: “Une description”}}

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, preprocessors=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, allow_default=True)[source]

set this.version

property json

Return JSON encoded representation of the request

class pywps.response.WPSResponse(wps_request: WPSRequest, 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.

classmethod from_json(value)[source]

init this request from json back again

Parameters

value – the json (not string) representation

property json

Return JSON encoded representation of the request

Refer Exceptions for their description.