Module Process

Process

Package for creating (Py)WPS Process classes

Class Status

class pywps.Process.Status

Status object for each process

creationTime

time.time()

code

“processstarted”, “processfailed” or anything else

percentCompleted

how far the calculation is

value

message string to the client

onStatusChanged()

Redefine this method in your functions

set(msg='', percentDone=0, propagate=True)

Set status message

Parameters:
  • msg (string) – message for the client
  • percentDone (int) – percent > 0 [0-99]
  • propagate (boolean) – call onStatusChanged method
setProcessStatus(code, value)

Sets current status of the process. Calls onStatusChanged method

Parameters:
  • code (string) – one of “processaccepted” “processstarted” “processsucceeded” “processpaused” “processfailed”
  • value (string) – additional message

Class WPSProcess

class pywps.Process.WPSProcess(identifier, title=None, abstract=None, metadata=[], profile=[], version='None', statusSupported=True, storeSupported=False, grassLocation=None, logFile=<open file '<stderr>', mode 'w'>)

Base class for any PyWPS Process

Parameters:
  • identifier (string) – process identifier
  • title (string) – process title
  • abstract (string) – process description
  • metadata

    List of additional metadata references. See http://www.opengeospatial.org/standards/common, table 32 on page 65, http://schemas.opengis.net/xlink/1.0.0/xlinks.xsd

    Example:

    [
        {
         "title": "Title",
         "href": "http://bnhelp.cz/metadata/micka_main.php?ak=detail&uuid=32e80880-c3b0-11dc-8641-873e117140a9",
         ... : ...
         }
    ]
    
  • profile ([string]) – profile URN
  • version – process version
  • statusSupported (boolean) – this process can be run asynchronously
  • storeSupported (boolean) – outputs from this process can be stored for later download
  • grassLocation – name of GRASS Location within “gisdbase” directory (from pywps.cfg configuration file). If set to True, temporary GRASS Location will be created and grass environment will be started. If None or False, no GRASS environment will be started.
identifier

Process identifier

version

Process version

metadata

List of references to metadata resources

title

Process title

abstract

Process abstract

wsdl

Not implemented

profile

Process profile

storeSupported

Indicates, whether the process supports storing of it’s results for later usage

statusSupported

Indicates, whether assynchronous running of the process is possible

debug

Print some information to log file

status

Instance of Status

inputs

List of process inputs, pywps.Process.InAndOutputs.Input

outputs

List of process outputs, pywps.Process.InAndOutputs.Output

lang

instance of pywps.Process.Lang.Lang class

grassLocation

Indicates, if and how GRASS GIS should be used

None/False
GRASS GIS is not used in any way. No location/mapset is created, no GRASS environment is initialized.
True

Temporary GRASS location is created. It is in XY reference coordinate system

Note

In the future, location should have the same coordinate system, as the input dataset is.

String
Name of existing GRASS Location (location name or full path), with existing PERMANENT mapset, where your Process can take input data from (or store results to). Temporary mapset within this location is created.
logFile

File object, where to print log in.

pywps

copy of the pywps.Pywps instance

addBBoxInput(identifier, title, abstract=None, metadata=[], minOccurs=1, maxOccurs=1, crss=['EPSG:4326'])

Add BoundingBox input

Parameters:
  • identifier (string) – input identifier
  • title (string) – input title
  • abstract (string) – input description.
  • metadata (list) – List of metadata references.
  • minOccurs – minimum number of occurrences.
  • maxOccurs (integer) – maximum number of occurrences.
  • crss (list) – of supported coordinate systems.
Returns:

pywps.Process.InAndOutputs.BoundingBoxInput

addBBoxOutput(identifier, title, abstract=None, crs='EPSG:4326', dimensions=2, asReference=False)

Add new output item of type BoundingBoxValue to this process

Parameters:
  • identifier – input identifier
  • title – input title
  • abstract – input description.
  • crss – List of strings supported coordinate systems.
  • dimensions – number of dimensions
  • asReference – output default asReference
Returns:

pywps.Process.InAndOutputs.BoundingBoxOutput

addComplexInput(identifier, title, abstract=None, metadata=[], minOccurs=1, maxOccurs=1, formats=[{'mimeType': None}], maxmegabites=None)

Add complex input to this process

Parameters:
  • identifier – input identifier
  • title – input title
  • abstract – input description.
  • minOccurs – minimum number of occurrences, default 1
  • maxOccurs – maximum number of occurrences, default 1
  • formats

    List of dictionary according to table 23 (page 25) OGC WPS.

    Example:

    [
        {"mimeType": "image/tiff"},
        {
            "mimeType": "text/xml",
            "encoding": "utf-8",
            "schema":"http://foo/bar"
        }
    ]
    
  • maxmegabites – Maximum input file size. Can not be bigger, as defined in global configuration file.
  • metadata

    List of additional metadata references. See http://www.opengeospatial.org/standards/common, table 32 on page 65, http://schemas.opengis.net/xlink/1.0.0/xlinks.xsd

    Example:

    [
        {
        "title": "Title",
        "href": "http://bnhelp.cz/metadata/micka_main.php?ak=detail&uuid=32e80880-c3b0-11dc-8641-873e117140a9",
        ... : ...
        }
    ]
    

    default: None

Returns:

pywps.Process.InAndOutputs.ComplexInput

addComplexOutput(identifier, title, abstract=None, metadata=[], formats=[{'mimeType': None}], useMapscript=False, asReference=False)

Add complex output to this process

Parameters:
  • identifier – output identifier
  • title – output title
  • metadata

    List of additional metadata references. See http://www.opengeospatial.org/standards/common, table 32 on page 65, http://schemas.opengis.net/xlink/1.0.0/xlinks.xsd

    Example:

    [
        {
        "title": "Title",
        "href": "http://bnhelp.cz/metadata/micka_main.php?ak=detail&uuid=32e80880-c3b0-11dc-8641-873e117140a9",
        ... : ...
        }
    ]
    

    default: None

  • formats

    List of dictionaries according to table 23 (page 25) of the standard

    [
        {"mimeType": "image/tiff"},
        {
            "mimeType": "text/xml",
            "encoding": "utf-8",
            "schema":"http://foo/bar"
        }
    ]
    
  • asReference – output default asReference
Returns:

pywps.Process.InAndOutputs.ComplexOutput

addLiteralInput(identifier, title, abstract=None, uoms=(), minOccurs=1, maxOccurs=1, allowedValues='*', type=<type 'int'>, default=None, metadata=[])

Add new input item of type LiteralValue to this process

Parameters:
  • identifier – input identifier
  • title – input title
  • abstract – input description.
  • uoms ([string]) – List of value units
  • minOccurs – minimum number of occurrences, default 1
  • maxOccurs – maximum number of occurrences, default 1
  • allowedValues

    List of of allowed values, which can be used with this input. You can set interval using list with two items, like:

    (1,2,3,(5,9),10,"a",("d","g"))
    

    This will produce allowed values 1,2,3,10, “a” and any value between 5 and 9 or “d” and “g”.

    If * is used, it means “any value” default (“*”)

  • type (types.TypeType) – value type, e.g. Integer, String, etc. you can uses the types module of python. default: types.IntType
  • default – default value of this input
  • metadata

    List of additional metadata references. See http://www.opengeospatial.org/standards/common, table 32 on page 65, http://schemas.opengis.net/xlink/1.0.0/xlinks.xsd

    Example:

    [
        {
        "title": "Title",
        "href": "http://bnhelp.cz/metadata/micka_main.php?ak=detail&uuid=32e80880-c3b0-11dc-8641-873e117140a9",
        ... : ...
        }
    ]
    

    default: None

Returns:

pywps.Process.InAndOutputs.LiteralInput

addLiteralOutput(identifier, title, abstract=None, metadata=[], uoms=(), type=<type 'int'>, default=None, asReference=False)

Add new output item of type LiteralValue to this process

Parameters:
  • identifier – input identifier
  • title – input title
  • abstract – input description.
  • uoms – List of string value units
  • typetypes.TypeType value type, e.g. Integer, String, etc. you can uses the types module of python.
  • default – default value, if any
  • metadata – List of additional metadata references. See http://www.opengeospatial.org/standards/common, table 32 on page 65, http://schemas.opengis.net/xlink/1.0.0/xlinks.xsd
  • asReference – output default asReference
Returns:

pywps.Process.InAndOutputs.LiteralOutput

cmd(cmd, stdin=None, stdout=True)

Command line commands (including GRASS modules)

Note

This module is supposed to be used instead of ‘os.system()’, while running GRASS modules

Parameters:
  • cmd ([string]) – the command, as list of parameters
  • stdin – string to be send into the command via standard in
  • stdout (boolean) – give stdout and stderror from the command back
Return type:

string

Returns:

standard ouput from the command

Example Usage:

self.cmd(["r.los","in=elevation.dem","out=los","coord=1000,1000"])

self.cmd(["v.net.path","network","afcol=forward","abcol=backward",
"out=mypath",'''nlayer=1","1 9 12"'''])

self.cmd(["d.mon","start=PNG"],stdout=False)
execute()

This method will be called by pywps.Wps.Execute.Execute. Please redefine this in your process instance

Returns:None if succeeded, error message otherwise.
getInput(identifier)

Get input defined by identifier

Parameters:identifier – input identifier
Returns:pywps.Process.InAndOutputs.Input
getInputValue(identifier)

Get input value according to identifier

Parameters:identifier – input identifier
Returns:None or self.inputs[identifier].value
getInputValues(identifier)

Get input values according to identifier :param identifier: input identifier :return: a list of input values

i18n(key)

Give back translation of defined key

Parameters:key – key value to be translated
Returns:translated string
initProcess(title=None, abstract=None, metadata=[], profile=[], version=None, statusSupported=True, storeSupported=False, grassLocation=None)

Can be used for later process re-initialization

For parameters, see constructor WPSProcess parameters.

message(msg, force=False)

Print some message to logfile

Parameters:
  • msg – print this string to logfile
  • force – if self.debug or force == True, the message will be printed. nothing happen otherwise.
setOutputValue(identifier, value)

Set output value

Parameters:
  • identifier – output identifier
  • value – value to be set

Table Of Contents

Previous topic

Module Execute

Next topic

Module Lang

This Page