Process
index
/home/jachym/usr/src/pywps/trunk/pywps/Process/Process.py

# Author:       Jachym Cepicky
#               http://les-ejk.cz
# Lince: 

# Web Processing Service implementation
# Copyright (C) 2006 Jachym Cepicky

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

 
Modules
       
InAndOutputs
Lang
subprocess
sys
time
types

 
Classes
       
Status
WPSProcess

 
class Status
    Status object for each process
 
Attributes:
creationTime time.time()
code {String} "processstarted", "processfailed" or anything else
percentCompleted {Float} how far the calculation is
value {String} message string to the client
 
  Methods defined here:
onStatusChanged(self)
To be redefined by other methods
set(self, msg='', percentDone=0, propagate=True)
Set status message
 
Parameters:
msg {String} message for the client
percentDone {Float} percent > 0
propagate {Boolean} call onStatusChanged method
setProcessStatus(self, 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

Data and other attributes defined here:
code = None
creationTime = 1220454837.6243529
percentCompleted = 0
value = None

 
class WPSProcess
    Base class for any PyWPS Process
 
  Methods defined here:
__init__(self, identifier, title=None, abstract=None, metadata=[], profile=[], version=None, statusSupported=True, storeSupported=False, grassLocation=None)
Process initialization. All parameters can be set lately
 
Mandatory parameters:
identifier {String} process identifier
title {String} process title
 
Optional parameters:
abstract {String} process description
        default: None
metadata List of {Dict} aditional metadata.  See
            http://www.opengeospatial.org/standards/common, table 32 on page 65
        E.g. {"foo":"bar"}
        default: None
profile {URN}
        default: None
version {String} process version
        default: None
statusSupported {Boolean} this process can be run assynchronously
        default: True
storeSupported {Boolean} outputs from this process can be stored
        for later dowload
        default: True
grassLocation {String} or {Boolean} name of GRASS Location within
        "grassdbase" 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.
        default: None
addBBoxInput(self, identifier, title, abstract=None, metadata=[], minOccurs=1, maxOccurs=1, crss=['EPSG:4326'])
Add BoundingBox input
 
Mandatory parameters:
identifier {String} input identifier
title {String} input title
 
Optional parameters:
abstract {String} input description. 
        default: None
metadata List of {Dict} {key:value} pairs. 
        default: None
minOccurs {Integer} minimum number of occurencies. 
        default: 1
maxOccurs {Integer} maximum number of occurencies. 
        default: 1
crss List of {String} supported coordinate systems.
        default: ["EPSG:4326"]
addBBoxOutput(self, identifier, title, abstract=None, crs='EPSG:4326', dimensions=2)
Add new output item of type BoundingBoxValue to this process 
 
Mandatory parameters:
identifier {String} input identifier
title {String} input title
 
Optional parameters:
abstract {String} input description. 
        default: None
crss List of {String} supported coordinate systems.
        default: ["EPSG:4326"]
dimensions {Integer} number of dimensions
        default: 2
addComplexInput(self, identifier, title, abstract=None, metadata=[], minOccurs=1, maxOccurs=1, formats=[{'mimeType': 'text/xml'}], maxmegabites=5)
Add complex input to this process
 
Mandatory parameters:
identifier {String} input identifier
title {String} input title
 
Optional parameters:
abstract {String} input description. 
        default: None
metadata List of {Dict} {key:value} pairs. 
        default: None
minOccurs {Integer} minimum number of occurencies. 
        default: 1
maxOccurs {Integer} maximum number of occurencies. 
        default: 1
formats List of {Dict} according to table 23 (page 25). E.g.
            [
                {"mimeType": "image/tiff"},
                {
                    "mimeType": "text/xml",
                    "encoding": "utf-8",
                    "schema":"http://foo/bar"
                }
            ]
        default: [{"mimeType":"text/xml"}]
maxmegabites {Float} Maximum input file size. Can not be bigger, as
        defined in global configuration file. 
        default: 5
addComplexOutput(self, identifier, title, abstract=None, metadata=[], formats=[{'mimeType': 'text/xml'}])
Add complex output to this process
 
Mandatory parameters:
identifier {String} output identifier
title {String} output title
 
Optional parameters:
metadata List of {Dict} {key:value} pairs. 
        default: None
formats List of {Dict} according to table 23 (page 25). E.g.
            [
                {"mimeType": "image/tiff"},
                {
                    "mimeType": "text/xml",
                    "encoding": "utf-8",
                    "schema":"http://foo/bar"
                }
            ]
        default: [{"mimeType":"text/xml"}]
addLiteralInput(self, 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
 
Mandatory parameters:
identifier {String} input identifier
title {String} input title
 
Optional parameters:
abstract {String} input description. Default: None
            default: None
uoms List of {String} value units
            default: ()
minOccurs {Integer} minimum number of occurencies. 
            default: 1
maxOccurs {Integer} maximum number of occurencies. 
            default: 1
allowedValues  List of {String} or {List} list 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 {Any} default value.
            default: None
metadata List of {Dict} Aditional metadata. E.g. {"foo":"bar"}
            default: None
addLiteralOutput(self, identifier, title, abstract=None, uoms=(), type=<type 'int'>, default=None)
Add new output item of type LiteralValue to this process
 
Mandatory parameters:
identifier {String} input identifier
title {String} input title
 
Optional parameters:
abstract {String} input description. Default: None
            default: None
uoms List of {String} value units
            default: ()
type {types.TypeType} value type, e.g. Integer, String, etc. you
            can uses the "types" module of python.
            default: types.IntType
default {Any} default value.
            default: None
cmd(self, cmd, stdin=None)
Runs GRASS command, fetches all GRASS_MESSAGE and
GRASS_PERCENT messages and sets self.status according to them, so
the client application can track the progress information, when
runing with Status=True
 
This module is supposed to be used instead of 'os.system()', while
running GRASS modules
 
Example Usage:
    Gcmd("r.los in=elevation.dem out=los coord=1000,1000")
 
    Gcmd("v.net.path network afcol=forward abcol=backward             out=mypath nlayer=1","1 9 12")
getInput(self, identifier)
Get input defined by identifier
 
Returns: None or Input
getInputValue(self, identifier)
Get input value according to identifier
 
Returns: None or self.inputs[identifier].value
i18n(self, key)
Give back translation of defined key
 
Returns: {String} translated string
initProcess(self, 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 __init__ method options.
message(self, msg, force=False)
Print some message to standard error
 
Parameters:
msg {String} print this string to standard error
force {Boolean} if self.debug or force == True, the message will be
        printed. nothing happen otherwise.
setOutputValue(self, identifier, value)
Set output value
 
Returns: None

Data and other attributes defined here:
abstract = None
debug = None
grassLocation = None
identifier = None
inputs = None
lang = None
metadata = None
outputs = None
profile = None
status = None
statusSupported = None
storeSupported = None
title = None
version = None
wsdl = None