Skip to content

Commit 468c901

Browse files
author
Alessio Fabiani
authored
Merge pull request #19 from geosolutions-it/master
- Version 2.14.1
2 parents bfa507b + 2eba26f commit 468c901

22 files changed

+106
-243
lines changed

.gitignore

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
*.py[cod]
22
*.suo
3+
*.bak
34

5+
/build/
46
RemoteWPS1.pyproj
57
RemoteWPS1.sln
6-
Include
7-
Lib/
8-
Scripts/
8+
/Include
9+
/Lib/
10+
/Scripts/
11+
12+
/RemoteWPS.pyproj
13+
/RemoteWPS.sln
14+
/.vs/config/applicationhost.config
15+
/dist/
16+
/src/wps_remote.egg-info/

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
setup(
3535
name = "wps-remote",
36-
version = "2.12.0",
36+
version = "2.14.1",
3737
author = "GeoServer Developers",
3838
author_email = "[email protected]",
3939
description = "A library that allows users to publish their executables as GeoServer WPS Processes through the XMPP protocol",

src/wps_remote.egg-info/PKG-INFO

-105
This file was deleted.

src/wps_remote.egg-info/SOURCES.txt

-52
This file was deleted.

src/wps_remote.egg-info/dependency_links.txt

-1
This file was deleted.

src/wps_remote.egg-info/requires.txt

-17
This file was deleted.

src/wps_remote.egg-info/top_level.txt

-1
This file was deleted.

src/wpsremote/computation_job_input.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414

1515
class ComputationJobInput(object):
1616

17-
def __init__(self, name, input_type, title, description, default=None, formatter=None):
17+
def __init__(self, name, input_type, title, description, default=None, formatter=None, input_mime_type=None):
1818
self._name = name
1919
self._type = input_type
2020
self._default = default
2121
self._formatter = formatter
2222
self._title = title
2323
self._description = description
24+
self._input_mime_type = input_mime_type
2425
self._value = None
2526
self._value_converted = None
2627
self._allowed_chars = string.printable.replace(' ','')
@@ -37,7 +38,7 @@ def _validate_and_convert(self, value):
3738
elif (self._type=='url'):
3839
if all(c in self._allowed_chars_url for c in value):
3940
return value
40-
elif self._type=='application/json':
41+
elif self._type in ['application/json', 'application/xml']:
4142
return json.loads(value)
4243
elif (self._type=='datetime'):
4344
if self._formatter:
@@ -52,15 +53,13 @@ def _validate_and_convert(self, value):
5253

5354
raise TypeError("Cannot validate and convert value " + str(value) + " for type " + self._type)
5455

55-
5656
def _type_checking(self, value):
5757
try:
5858
self._validate_and_convert( value )
5959
return self._type
6060
except TypeError:
6161
return False
62-
63-
62+
6463
def validate(self):
6564
if (not self.has_value()):
6665
raise TypeError("cannot find a value for parameter " + self.get_name())
@@ -84,14 +83,12 @@ def set_value(self, value):
8483

8584
res = False
8685
try:
87-
res= self.validate()
86+
res = self.validate()
8887
if not res:
8988
raise TypeError("cannot set value " + str(self._value) + " for parameter " + self.get_name() + " with type " + self._type)
9089
except:
9190
raise TypeError("cannot set value " + str(self._value) + " for parameter " + self.get_name() + " with type " + self._type)
9291

93-
94-
9592
def get_value(self):
9693
if type(self._value_converted) is list and len(self._value_converted)==1:
9794
return self._value_converted[0]
@@ -101,6 +98,9 @@ def get_value(self):
10198
def get_type(self):
10299
return self._type
103100

101+
def get_input_mime_type(self):
102+
return self._input_mime_type
103+
104104
def get_value_string(self):
105105
if type(self._value) is list and len(self._value)==1:
106106
if type(self._value[0]) is datetime.datetime:
@@ -138,7 +138,7 @@ def get_name(self):
138138
def as_json_string(self):
139139
#{"type": "string", "description": "A persons surname", "max": 1, "default": "Meier"}
140140
res={}
141-
attrib_to_convert = ['_type', "_title", "_default", "_description", "_min", "_max"] #missing _enum
141+
attrib_to_convert = ['_type', '_title', '_default', '_description', '_min', '_max', '_input_mime_type'] #missing _enum
142142
attribute_list = [a for a in dir(self) if not a.startswith('__') and not callable(getattr(self, a))]
143143
attribute_list_filtered = [x for x in attribute_list if x in attrib_to_convert]
144144
for a in attribute_list_filtered:

src/wpsremote/computation_job_inputs.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ def create_from_dict(paremeters_types_defs):
4444
formatter = d['formatter'] if "formatter" in d else None
4545
mininum = int(d['min']) if "min" in d else 1
4646
maximum = int(d['max']) if "max" in d else 1
47-
input_to_add = computation_job_param.ComputationJobParam(name, d['type'], title, d['description'], default, formatter, mininum, maximum)
47+
input_mime_type = d['input_mime_type'] if "input_mime_type" in d else None
48+
input_to_add = computation_job_param.ComputationJobParam(name, d['type'], title, d['description'], default, formatter, mininum, maximum, input_mime_type)
4849
elif d['class'] == 'const':
4950
title = d['title'] if "title" in d else None
5051
input_to_add = computation_job_const.ComputationJobConst(name, d['type'], title, d['description'], d['value'])
@@ -53,7 +54,7 @@ def create_from_dict(paremeters_types_defs):
5354
else:
5455
raise TypeError("Cannot create computational job input without attribute class")
5556
cji.add_input( input_to_add )
56-
57+
5758
return cji
5859

5960
def __init__(self):
@@ -88,7 +89,6 @@ def names(self):
8889
def __getitem__(self, k):
8990
return self._inputs[k]
9091

91-
9292
def as_DLR_protocol(self):
9393
#[('result', '{"type": "string", ...ut.xml" }')]
9494
res = []

src/wpsremote/computation_job_param.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
class ComputationJobParam(computation_job_input.ComputationJobInput):
1414

15-
def __init__(self, name, input_type, title, descr, default=None, formatter=None, min_occurencies=0, max_occurencies=1):
16-
super(ComputationJobParam, self).__init__(name, input_type, title, descr, default, formatter)
15+
def __init__(self, name, input_type, title, descr, default=None, formatter=None, min_occurencies=0, max_occurencies=1, input_mime_type=None):
16+
super(ComputationJobParam, self).__init__(name, input_type, title, descr, default, formatter, input_mime_type)
1717
self._min = min_occurencies
1818
self._max = max_occurencies
1919

src/wpsremote/input_parameter.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import json
1414

1515
class InputParameter(object):
16+
1617
def __init__(self, name):
1718
self._name=name
1819
self._alias=None
@@ -23,6 +24,7 @@ def __init__(self, name):
2324
self._max=1
2425
self._default = None
2526
self._formatter = None
27+
self._input_mime_type = None
2628
self._allowed_chars = string.printable.replace('-','').replace(' ','')
2729

2830
self._value=None
@@ -90,6 +92,9 @@ def validate(self):
9092
def get_name(self):
9193
return self._alias if self._alias <> None else self._name
9294

95+
def get_input_mime_type(self):
96+
return self._input_mime_type
97+
9398
def get_name_no_alias(self):
9499
return self._name
95100

@@ -99,9 +104,9 @@ def get_cmd_line(self):
99104
def as_json_string(self):
100105
#{"type": "string", "description": "A persons surname", "max": 1, "default": "Meier"}
101106
res={}
102-
attrib_to_convert = ['_type', "_title", "_description", "_min", "_max", "_default"]
107+
attrib_to_convert = ['_type', '_title', '_description', '_min', '_max', '_default', '_input_mime_type']
103108
attribute_list = [a for a in dir(self) if not a.startswith('__') and not callable(getattr(self, a))]
104109
attribute_list_filtered = [x for x in attribute_list if x in attrib_to_convert]
105110
for a in attribute_list_filtered:
106111
res[a[1:]] = getattr(self, a)
107-
return json.dumps(res)
112+
return json.dumps(res)

src/wpsremote/input_parameters.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@
1515

1616
class InputParameters(object):
1717

18-
1918
@staticmethod
2019
def create_from_config(input_sections):
2120
'''Create a InputParameters object.
2221
2322
input_sections: a dictionary such as { input1 : [( 'par1_input1_name' , par1_input1_value ), ( 'par2_input1_name' , par2_input1_value ), ...], input2 : [ .... ], ... }
2423
'''
25-
input_sections_reshaped=OrderedDict()
24+
input_sections_reshaped = OrderedDict()
2625
#force the order of sections in config files: [input1], [input2], etc
2726
for k in sorted(input_sections):
2827
d=dict(input_sections[k])
@@ -88,12 +87,12 @@ def checkForCodeInsertion(self, argList):
8887
maliciousCommands = ['>', '<', '>>', '|', '>&', '<&']
8988
# Check for bad code insertion
9089
maliciousCode = ['eval(', 'exec(', 'execfile(', 'input(']
91-
90+
9291
# Evaluate malicious commands
9392
if any(e in maliciousCommands for e in argList):
9493
raise IOError('Found bad code in user input')
9594
# Evaluate maliciousCode
9695
for element in argList:
9796
for code in maliciousCode:
9897
if code in element:
99-
raise IOError('Found bad code in user input')
98+
raise IOError('Found bad code in user input')

0 commit comments

Comments
 (0)