[Pywps-commits] r583 - in trunk: . pywps/Process pywps/Templates/inc pywps/Wps pywps/processes

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Sep 9 08:40:12 CEST 2008


Author: jachym
Date: 2008-09-09 08:40:11 +0200 (Tue, 09 Sep 2008)
New Revision: 583

Modified:
   trunk/MANIFEST.in
   trunk/pywps/Process/InAndOutputs.py
   trunk/pywps/Process/Process.py
   trunk/pywps/Templates/inc/DescribeProcess_LiteralValue.tmpl
   trunk/pywps/Wps/DescribeProcess.py
   trunk/pywps/processes/exampleBufferProcess.py
Log:
applygin patch from Panagiotis Skintzos:
Parameter parsing in InAndOutputs.py:
- set allowed values when they passed as list (line 158)
- setValue function modified to allow list & non-list values (before it was iterating inside string values)
- added boolean type conversion in _control function
- removed uninitialized e parameter from last InvalidParameterValue exception in _control function

Corrected getInputValue function of Process.py. It calls getValue from the input class so that it can return the default value if exists.

Added missing ows:Value closing tag in DescribeProcess_LiteralValue.tmpl

Fixed typos and empty array for allowed values in line 195 of DescribeProcess.py


Modified: trunk/MANIFEST.in
===================================================================
--- trunk/MANIFEST.in	2008-09-08 13:05:47 UTC (rev 582)
+++ trunk/MANIFEST.in	2008-09-09 06:40:11 UTC (rev 583)
@@ -1,6 +1,6 @@
 include setup.py
 
-graft pywps/WPS
+graft pywps/Wps
 graft pywps/processes
 graft pywps/etc
 graft pywps/Parser

Modified: trunk/pywps/Process/InAndOutputs.py
===================================================================
--- trunk/pywps/Process/InAndOutputs.py	2008-09-08 13:05:47 UTC (rev 582)
+++ trunk/pywps/Process/InAndOutputs.py	2008-09-09 06:40:11 UTC (rev 583)
@@ -157,6 +157,8 @@
         self.restrictedCharacters = ['\\',"#",";", "&","!"]
         if type(values) == types.StringType:
             self.values = (values)
+        elif type(values) == types.ListType:
+            self.values = values
         self.default = default
         self.spacing = spacing
         self.uom = None 
@@ -165,8 +167,13 @@
     def setValue(self, input):
         """Set input value value to this input"""
 
-        for inpt in input["value"]:
-            resp = self._setValueWithOccurence(self.value, self._control(inpt))
+        if type(input["value"]) == types.ListType:
+            for inpt in input["value"]:
+                resp = self._setValueWithOccurence(self.value, self._control(inpt))
+                if resp:
+                    return resp
+        else:
+            resp = self._setValueWithOccurence(self.value, self._control(input["value"]))
             if resp:
                 return resp
 
@@ -201,6 +208,8 @@
                 value = str(value)
             elif self.dataType == types.IntType:
                 value = int(value)
+            elif self.dataType == types.BooleanType:
+                value = bool(value)
             #TODO other types missing
         except (ValueError), e:
             raise Exceptions.InvalidParameterValue(value,e)
@@ -222,7 +231,7 @@
                 if str(value) == str(allowed):
                     return value
             
-        raise Exceptions.InvalidParameterValue(value,e)
+        raise Exceptions.InvalidParameterValue(value)
 
 class ComplexInput(Input):
     """ComplexInput type"""

Modified: trunk/pywps/Process/Process.py
===================================================================
--- trunk/pywps/Process/Process.py	2008-09-08 13:05:47 UTC (rev 582)
+++ trunk/pywps/Process/Process.py	2008-09-09 06:40:11 UTC (rev 583)
@@ -469,7 +469,7 @@
         """
 
         try:
-            return self.inputs[identifier].value
+            return self.inputs[identifier].getValue()
         except:
             return None
 

Modified: trunk/pywps/Templates/inc/DescribeProcess_LiteralValue.tmpl
===================================================================
--- trunk/pywps/Templates/inc/DescribeProcess_LiteralValue.tmpl	2008-09-08 13:05:47 UTC (rev 582)
+++ trunk/pywps/Templates/inc/DescribeProcess_LiteralValue.tmpl	2008-09-09 06:40:11 UTC (rev 583)
@@ -27,7 +27,7 @@
                             </ows:Range>
                         </TMPL_IF>
                         <TMPL_IF discrete>
-                            <ows:Value><TMPL_VAR value>
+                            <ows:Value><TMPL_VAR value></ows:Value>
                         </TMPL_IF>
                         </TMPL_LOOP>
                     </ows:AllowedValues>

Modified: trunk/pywps/Wps/DescribeProcess.py
===================================================================
--- trunk/pywps/Wps/DescribeProcess.py	2008-09-08 13:05:47 UTC (rev 582)
+++ trunk/pywps/Wps/DescribeProcess.py	2008-09-09 06:40:11 UTC (rev 583)
@@ -193,12 +193,13 @@
                     valrecord = {}
                     if type(val) == type([]):
                         valrecord["minMax"] = 1
-                        valercord["minimumValue"] = val[0]
-                        valercord["maximumValue"] = val[-1]
-                        valercord["spacing"] = inoutput.spacing
+                        valrecord["minimumValue"] = val[0]
+                        valrecord["maximumValue"] = val[-1]
+                        valrecord["spacing"] = inoutput.spacing
                     else:
                         valrecord["discrete"] = 1
                         valrecord["value"] = val
+                    processInOutput["allowedValues"].append(valrecord)
         except AttributeError:
             pass
 

Modified: trunk/pywps/processes/exampleBufferProcess.py
===================================================================
--- trunk/pywps/processes/exampleBufferProcess.py	2008-09-08 13:05:47 UTC (rev 582)
+++ trunk/pywps/processes/exampleBufferProcess.py	2008-09-09 06:40:11 UTC (rev 583)
@@ -47,6 +47,11 @@
         self.bufferRasterOut = self.addComplexOutput(identifier="bufferRaster",
                                 title="Output buffer as Raster",
                                 formats=[{"mimeType":"image/tiff"}])
+
+        # complex raster output
+        self.asPNG = self.addComplexOutput(identifier="asPNG",
+                                title="Output buffer as Raster in PNG format",
+                                formats=[{"mimeType":"image/png"}])
         # literal output
         self.textOut = self.addLiteralOutput(identifier="text",
                                 title="Just some literal output")
@@ -70,6 +75,13 @@
                 (self.getInputValue('data')))
 	self.cmd("g.region vect=data")
 
+        # creating output with GRASS PNG driver
+        import os
+        self.cmd("d.mon start=PNG",stdout=False)
+        self.cmd("d.vect data")
+        self.cmd("d.mon stop=PNG")
+        self.asPNG.setValue("map.png")
+
         # buffer
         self.status.set("Buffering",50)
 	self.cmd("v.buffer input=data output=data_buff buffer=%s scale=1.0 tolerance=0.01" %\



More information about the Pywps-commits mailing list