source: TI05-delivery/ows_framework/trunk/ows_wps/ows_wps/execute.py @ 2659

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI05-delivery/ows_framework/trunk/ows_wps/ows_wps/execute.py@2659
Revision 2659, 2.5 KB checked in by spascoe, 15 years ago (diff)

Commiting midway through development to change platform. Various classes
have been added to support process execution.

Line 
1# Copyright (C) 2007 STFC & NERC (Science and Technology Facilities Council).
2# This software may be distributed under the terms of the
3# Q Public License, version 1.0 or later.
4# http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt
5"""
6Classes modelling the WPS 0.4 Execute package.
7
8WPS 0.4 contains 3 separate data structures for representing output options:
91. ProcessDescription/ProcessOutputs/OutputDescription describes possible
10   formats for an output.
112. Execute(Response)/OutputDefinitions/OutputDefinition describes the
12   selected format for an output.
133. ExecuteResponse/ProcessOutputs/IOValue describes the actual output.
14
15Of these only OutputDescription is modelled directly (in the
16process_description module).  The framework maps the
17ExecuteStatus.inputs and ExecuteStatus.outputs dictionaries onto these
18structures.
19
20"""
21
22from ows_common.data_identification import BasicIdentification
23
24class ExecuteStatus(object):
25    """
26    This class models the parts of WPS ExecuteRequest and
27    ExecuteResponse that are under the control of the process.  Other
28    parts are handled by the framework.
29
30    The inputs and outputs dictionary should share keys with the
31    description.inputs/outputs attributes respectively.
32   
33    @ivar flag
34    @type flag: One of PENDING, ACCEPTED, STARTED, SUCCEEDED, FAILED
35    @ivar message: This is the message put in the Status XML element
36    @type message: str
37    @ivar percentComplete
38    @type percentComplete: int or None
39
40    @ivar inputs
41    @type inputs: dictionary mapping input identifiers to python objects
42    @ivar outputs
43    @type outputs: dictionary mapping output identifiers to python objects
44
45    @ivar exceptionReport
46    @type exceptionReport: ExceptionReport if self.status=self.FAILED else None
47
48    """
49    PENDING = 'PENDING'
50    ACCEPTED = 'ACCEPTED'
51    STARTED = 'STARTED'
52    SUCCEEDED = 'SUCCEEDED'
53    FAILED = 'FAILED'
54   
55    def __init__(self, inputs=[], outputs=[], message=''):
56        self.flag = self.PENDING
57        self.message = message
58        self.percentComplete = None
59        self.inputs = inputs
60        self.outputs = outputs
61        self.exceptionReport = None
62
63    def setOutputs(self, **outputs):
64        """
65        Ensure the keys in outputs match self.description.outputs and
66        set self.outputs accordingly.
67
68        """
69        for k in outputs:
70            if k in self.description.outputs:
71                self.outputs[k] = outputs[k]
72            else:
73                raise ValueError("Output %s not in description" % k)
74
Note: See TracBrowser for help on using the repository browser.