Skip to content

Commit

Permalink
- Version 2.14.1
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Sep 14, 2018
1 parent 42a24b4 commit 2eba26f
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,5 +1,6 @@
*.py[cod]
*.suo
*.bak

/build/
RemoteWPS1.pyproj
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -33,7 +33,7 @@

setup(
name = "wps-remote",
version = "2.14.0",
version = "2.14.1",
author = "GeoServer Developers",
author_email = "geoserver-devel@lists.sourceforge.net",
description = "A library that allows users to publish their executables as GeoServer WPS Processes through the XMPP protocol",
Expand Down
18 changes: 9 additions & 9 deletions src/wpsremote/computation_job_input.py
Expand Up @@ -14,13 +14,14 @@

class ComputationJobInput(object):

def __init__(self, name, input_type, title, description, default=None, formatter=None):
def __init__(self, name, input_type, title, description, default=None, formatter=None, input_mime_type=None):
self._name = name
self._type = input_type
self._default = default
self._formatter = formatter
self._title = title
self._description = description
self._input_mime_type = input_mime_type
self._value = None
self._value_converted = None
self._allowed_chars = string.printable.replace(' ','')
Expand All @@ -37,7 +38,7 @@ def _validate_and_convert(self, value):
elif (self._type=='url'):
if all(c in self._allowed_chars_url for c in value):
return value
elif self._type=='application/json':
elif self._type in ['application/json', 'application/xml']:
return json.loads(value)
elif (self._type=='datetime'):
if self._formatter:
Expand All @@ -52,15 +53,13 @@ def _validate_and_convert(self, value):

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


def _type_checking(self, value):
try:
self._validate_and_convert( value )
return self._type
except TypeError:
return False



def validate(self):
if (not self.has_value()):
raise TypeError("cannot find a value for parameter " + self.get_name())
Expand All @@ -84,14 +83,12 @@ def set_value(self, value):

res = False
try:
res= self.validate()
res = self.validate()
if not res:
raise TypeError("cannot set value " + str(self._value) + " for parameter " + self.get_name() + " with type " + self._type)
except:
raise TypeError("cannot set value " + str(self._value) + " for parameter " + self.get_name() + " with type " + self._type)



def get_value(self):
if type(self._value_converted) is list and len(self._value_converted)==1:
return self._value_converted[0]
Expand All @@ -101,6 +98,9 @@ def get_value(self):
def get_type(self):
return self._type

def get_input_mime_type(self):
return self._input_mime_type

def get_value_string(self):
if type(self._value) is list and len(self._value)==1:
if type(self._value[0]) is datetime.datetime:
Expand Down Expand Up @@ -138,7 +138,7 @@ def get_name(self):
def as_json_string(self):
#{"type": "string", "description": "A persons surname", "max": 1, "default": "Meier"}
res={}
attrib_to_convert = ['_type', "_title", "_default", "_description", "_min", "_max"] #missing _enum
attrib_to_convert = ['_type', '_title', '_default', '_description', '_min', '_max', '_input_mime_type'] #missing _enum
attribute_list = [a for a in dir(self) if not a.startswith('__') and not callable(getattr(self, a))]
attribute_list_filtered = [x for x in attribute_list if x in attrib_to_convert]
for a in attribute_list_filtered:
Expand Down
6 changes: 3 additions & 3 deletions src/wpsremote/computation_job_inputs.py
Expand Up @@ -44,7 +44,8 @@ def create_from_dict(paremeters_types_defs):
formatter = d['formatter'] if "formatter" in d else None
mininum = int(d['min']) if "min" in d else 1
maximum = int(d['max']) if "max" in d else 1
input_to_add = computation_job_param.ComputationJobParam(name, d['type'], title, d['description'], default, formatter, mininum, maximum)
input_mime_type = d['input_mime_type'] if "input_mime_type" in d else None
input_to_add = computation_job_param.ComputationJobParam(name, d['type'], title, d['description'], default, formatter, mininum, maximum, input_mime_type)
elif d['class'] == 'const':
title = d['title'] if "title" in d else None
input_to_add = computation_job_const.ComputationJobConst(name, d['type'], title, d['description'], d['value'])
Expand All @@ -53,7 +54,7 @@ def create_from_dict(paremeters_types_defs):
else:
raise TypeError("Cannot create computational job input without attribute class")
cji.add_input( input_to_add )

return cji

def __init__(self):
Expand Down Expand Up @@ -88,7 +89,6 @@ def names(self):
def __getitem__(self, k):
return self._inputs[k]


def as_DLR_protocol(self):
#[('result', '{"type": "string", ...ut.xml" }')]
res = []
Expand Down
4 changes: 2 additions & 2 deletions src/wpsremote/computation_job_param.py
Expand Up @@ -12,8 +12,8 @@

class ComputationJobParam(computation_job_input.ComputationJobInput):

def __init__(self, name, input_type, title, descr, default=None, formatter=None, min_occurencies=0, max_occurencies=1):
super(ComputationJobParam, self).__init__(name, input_type, title, descr, default, formatter)
def __init__(self, name, input_type, title, descr, default=None, formatter=None, min_occurencies=0, max_occurencies=1, input_mime_type=None):
super(ComputationJobParam, self).__init__(name, input_type, title, descr, default, formatter, input_mime_type)
self._min = min_occurencies
self._max = max_occurencies

Expand Down
9 changes: 7 additions & 2 deletions src/wpsremote/input_parameter.py
Expand Up @@ -13,6 +13,7 @@
import json

class InputParameter(object):

def __init__(self, name):
self._name=name
self._alias=None
Expand All @@ -23,6 +24,7 @@ def __init__(self, name):
self._max=1
self._default = None
self._formatter = None
self._input_mime_type = None
self._allowed_chars = string.printable.replace('-','').replace(' ','')

self._value=None
Expand Down Expand Up @@ -90,6 +92,9 @@ def validate(self):
def get_name(self):
return self._alias if self._alias <> None else self._name

def get_input_mime_type(self):
return self._input_mime_type

def get_name_no_alias(self):
return self._name

Expand All @@ -99,9 +104,9 @@ def get_cmd_line(self):
def as_json_string(self):
#{"type": "string", "description": "A persons surname", "max": 1, "default": "Meier"}
res={}
attrib_to_convert = ['_type', "_title", "_description", "_min", "_max", "_default"]
attrib_to_convert = ['_type', '_title', '_description', '_min', '_max', '_default', '_input_mime_type']
attribute_list = [a for a in dir(self) if not a.startswith('__') and not callable(getattr(self, a))]
attribute_list_filtered = [x for x in attribute_list if x in attrib_to_convert]
for a in attribute_list_filtered:
res[a[1:]] = getattr(self, a)
return json.dumps(res)
return json.dumps(res)
7 changes: 3 additions & 4 deletions src/wpsremote/input_parameters.py
Expand Up @@ -15,14 +15,13 @@

class InputParameters(object):


@staticmethod
def create_from_config(input_sections):
'''Create a InputParameters object.
input_sections: a dictionary such as { input1 : [( 'par1_input1_name' , par1_input1_value ), ( 'par2_input1_name' , par2_input1_value ), ...], input2 : [ .... ], ... }
'''
input_sections_reshaped=OrderedDict()
input_sections_reshaped = OrderedDict()
#force the order of sections in config files: [input1], [input2], etc
for k in sorted(input_sections):
d=dict(input_sections[k])
Expand Down Expand Up @@ -88,12 +87,12 @@ def checkForCodeInsertion(self, argList):
maliciousCommands = ['>', '<', '>>', '|', '>&', '<&']
# Check for bad code insertion
maliciousCode = ['eval(', 'exec(', 'execfile(', 'input(']

# Evaluate malicious commands
if any(e in maliciousCommands for e in argList):
raise IOError('Found bad code in user input')
# Evaluate maliciousCode
for element in argList:
for code in maliciousCode:
if code in element:
raise IOError('Found bad code in user input')
raise IOError('Found bad code in user input')
15 changes: 11 additions & 4 deletions src/wpsremote/output_file_parameter.py
Expand Up @@ -63,7 +63,7 @@ def as_json_string(self):
attribute_list_filtered = [x for x in attribute_list if x in attrib_to_convert]
for a in attribute_list_filtered:
res[a[1:]] = getattr(self, a)
return json.dumps(res)
return json.dumps(res)

def get_value(self):
if self._backup_on_wps_execution_shared_dir != None and self._backup_on_wps_execution_shared_dir and self._wps_execution_shared_dir != None:
Expand Down Expand Up @@ -103,6 +103,9 @@ def get_description(self):
def get_title(self):
return self._title

def get_output_mime_type(self):
return self._output_mime_type

def is_publish_as_layer(self):
return (self._publish_as_layer != None and self._publish_as_layer == "true")

Expand Down Expand Up @@ -208,6 +211,9 @@ def get_description(self):
def get_title(self):
return self._title

def get_output_mime_type(self):
return self._output_mime_type

def is_publish_as_layer(self):
return (self._publish_as_layer != None and self._publish_as_layer == "true")

Expand Down Expand Up @@ -314,7 +320,7 @@ def get_value(self):
dst = bkp_dir.abspath() + "/" + filepath.basename()
filepath.copy(dst)
dst = path.path(dst)

if len(files_to_publish) > 0:
files_to_publish = files_to_publish + ";"
files_to_publish = files_to_publish + dst.abspath()
Expand Down Expand Up @@ -356,6 +362,9 @@ def get_description(self):
def get_title(self):
return self._title

def get_output_mime_type(self):
return self._output_mime_type

def is_publish_as_layer(self):
return (self._publish_as_layer != None and self._publish_as_layer == "true")

Expand All @@ -375,5 +384,3 @@ def get_metadata(self):
if metadata_file.isfile():
return metadata_file.text()
return ' '


1 change: 1 addition & 0 deletions src/wpsremote/servicebot.py
Expand Up @@ -31,6 +31,7 @@


class ServiceBot(object):

"""This script is the remote WPS agent. One instance of this agent runs on each computational node connected to the WPS for each algorithm available. The script runs continuosly.
"""
def __init__(self, remote_config_filepath, service_config_filepath):
Expand Down
3 changes: 2 additions & 1 deletion src/wpsremote/xmpp_data/configs/myservice/service.config
Expand Up @@ -42,7 +42,8 @@ process_blacklist = [resource consuming process name1, resource consuming proces
class = param
name = interval
title = Elevation Interval
type = int
type = application/json
input_mime_type = application/json
description = Elevation interval between contours.
min = 1
max = 1
Expand Down

0 comments on commit 2eba26f

Please sign in to comment.