Skip to content

Commit

Permalink
- patch: boolean string properties checks are wrong on "output_file_…
Browse files Browse the repository at this point in the history
…parameter"
  • Loading branch information
afabiani committed Sep 27, 2018
1 parent c3f64e3 commit 55d55fb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -33,7 +33,7 @@

setup(
name = "wps-remote",
version = "2.14.3",
version = "2.14.4",
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
Expand Up @@ -21,7 +21,7 @@ def __init__(self, input_ref, json_filepath, json_path_expr=None, json_schema=No
self._input_ref = input_ref
self._json_filepath = json_filepath if isinstance(json_filepath, path.path) else path.path(json_filepath)

# Python-like expression to access json data in memory.
# Python-like expression to access json data in memory.
# This value is used in case of multiple json file creation to enumerate the file names (e.g. outfile1.json, outfile2.json) using an id from the input json data
self._json_path_expr = json_path_expr
self.json_files_created = []
Expand All @@ -30,7 +30,7 @@ def __init__(self, input_ref, json_filepath, json_path_expr=None, json_schema=No
self._json_schema = json.loads(json_schema.text())
else:
self._json_schema = json.loads(json_schema)


def set_inputs(self, inputs):
#for par_name in self._input_refs:
Expand Down Expand Up @@ -64,7 +64,7 @@ def validate_json(self, json_text):
msg = "Invalid json for asset: " + str(ex)
logger.fatal(msg)
raise ex

def create_json_file(self, json_text):
json_filepath = self._extract_id_from_json(json_text)
#json_filepath.write_text( json_text )
Expand All @@ -75,7 +75,7 @@ def create_json_file(self, json_text):


def _extract_id_from_json(self, json_text):
if self._json_path_expr != None and not self._json_path_expr:
if self._json_path_expr != None and self._json_path_expr != '':
_id = eval( "json_text" + self._json_path_expr )
self._json_filepath = str(self._json_filepath).replace('${json_path_expr}', '%i')
fp = self._json_filepath % _id
Expand All @@ -87,4 +87,3 @@ def exists(self):
files_exists = map(lambda fp: fp.exists(), self.json_files_created)
files_exists = list(set(files_exists))
return len(files_exists)==1 and files_exists[0]

38 changes: 19 additions & 19 deletions src/wpsremote/output_file_parameter.py
Expand Up @@ -20,7 +20,7 @@
# #
# ############################################################################################################# #
class OutputFileParameter(object):

def __init__(self, par_name, d, template_vars_for_param_types=None, wps_execution_shared_dir=None, uploader=None):
#{"type": "string", "description": "xml OAA output file", "filepath" : "%workdir\\\\output_file.xml" }
self._name=par_name
Expand All @@ -47,7 +47,7 @@ def __init__(self, par_name, d, template_vars_for_param_types=None, wps_executio
for var, val in template_vars_for_param_types.items():
if var in v:
v=v.replace("%" + var,val)

setattr(self, "_" + k, v)

self._filepath = path.path(self._filepath)
Expand All @@ -66,7 +66,7 @@ def as_json_string(self):
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:
if self._backup_on_wps_execution_shared_dir != None and self._backup_on_wps_execution_shared_dir.lower() is "true" and self._wps_execution_shared_dir != None:
unique_dirname = str(uuid.uuid4())
bkp_dir = path.path(self._wps_execution_shared_dir + "/" + unique_dirname)
bkp_dir.makedirs()
Expand All @@ -76,7 +76,7 @@ def get_value(self):
dst = path.path(dst)

return dst.text()
elif self._upload_data != None and self._upload_data and self._uploader != None:
elif self._upload_data != None and self._upload_data.lower() is "true" and self._uploader != None:
unique_dirname = str(uuid.uuid4())
bkp_dir = path.path(tempfile.gettempdir() + '/' + unique_dirname)
bkp_dir.makedirs()
Expand Down Expand Up @@ -107,7 +107,7 @@ 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")
return (self._publish_as_layer != None and self._publish_as_layer.lower() is "true")

def get_publish_layer_name(self):
return self._publish_layer_name
Expand All @@ -123,7 +123,7 @@ def get_metadata(self):
metadata_file = path.path(self._publish_metadata)

if metadata_file.isfile():
return metadata_file.text()
return metadata_file.text()
return ' '

# ############################################################################################################# #
Expand All @@ -132,7 +132,7 @@ def get_metadata(self):
# #
# ############################################################################################################# #
class RawFileParameter(object):

def __init__(self, par_name, d, template_vars_for_param_types=None, wps_execution_shared_dir=None, uploader=None):
#{"type": "string", "description": "xml OAA output file", "filepath" : "%workdir\\\\output_file.xml" }
self._name=par_name
Expand All @@ -159,7 +159,7 @@ def __init__(self, par_name, d, template_vars_for_param_types=None, wps_executio
for var, val in template_vars_for_param_types.items():
if var in v:
v=v.replace("%" + var,val)

setattr(self, "_" + k, v)

self._filepath = path.path(self._filepath)
Expand All @@ -178,7 +178,7 @@ def as_json_string(self):
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:
if self._backup_on_wps_execution_shared_dir != None and self._backup_on_wps_execution_shared_dir.lower() is "true" and self._wps_execution_shared_dir != None:
unique_dirname = str(uuid.uuid4())
bkp_dir = path.path(self._wps_execution_shared_dir + "/" + unique_dirname)
bkp_dir.makedirs()
Expand All @@ -188,9 +188,9 @@ def get_value(self):
dst = path.path(dst)

return dst
elif self._upload_data != None and self._upload_data and self._uploader != None:
elif self._upload_data != None and self._upload_data.lower() is "true" and self._uploader != None:
unique_dirname = str(uuid.uuid4())

if self._upload_data_root:
unique_dirname = self._upload_data_root + '/' + unique_dirname
src_path = os.path.abspath(os.path.join(self._filepath.abspath(), os.pardir))
Expand All @@ -215,7 +215,7 @@ 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")
return (self._publish_as_layer != None and self._publish_as_layer.lower() is "true")

def get_publish_layer_name(self):
return self._publish_layer_name
Expand All @@ -231,7 +231,7 @@ def get_metadata(self):
metadata_file = path.path(self._publish_metadata)

if metadata_file.isfile():
return metadata_file.text()
return metadata_file.text()
return ' '


Expand All @@ -241,7 +241,7 @@ def get_metadata(self):
# #
# ############################################################################################################# #
class OWCFileParameter(object):

def __init__(self, par_name, d, parameters_types_defs, template_vars_for_param_types=None, wps_execution_shared_dir=None, uploader=None):
#{"type": "string", "description": "xml OAA output file", "filepath" : "%workdir\\\\output_file.xml" }
self._name=par_name
Expand All @@ -267,7 +267,7 @@ def __init__(self, par_name, d, parameters_types_defs, template_vars_for_param_t
for var, val in template_vars_for_param_types.items():
if var in v:
v=v.replace("%" + var,val)

setattr(self, "_" + k, v)

self._files_to_publish = ''
Expand Down Expand Up @@ -307,7 +307,7 @@ def as_json_string(self):
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:
if self._backup_on_wps_execution_shared_dir != None and self._backup_on_wps_execution_shared_dir.lower() is "true" and self._wps_execution_shared_dir != None:
unique_dirname = str(uuid.uuid4())
bkp_dir = path.path(self._wps_execution_shared_dir + "/" + unique_dirname)
bkp_dir.makedirs()
Expand All @@ -326,7 +326,7 @@ def get_value(self):
files_to_publish = files_to_publish + dst.abspath()

return files_to_publish
elif self._upload_data != None and self._upload_data and self._uploader != None:
elif self._upload_data != None and self._upload_data.lower() is "true" and self._uploader != None:
unique_dirname = str(uuid.uuid4())
bkp_dir = path.path(tempfile.gettempdir() + '/' + unique_dirname)
bkp_dir.makedirs()
Expand Down Expand Up @@ -366,7 +366,7 @@ 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")
return (self._publish_as_layer != None and self._publish_as_layer.lower() is "true")

def get_publish_layer_name(self):
return self._publish_layer_name
Expand All @@ -382,5 +382,5 @@ def get_metadata(self):
metadata_file = path.path(self._publish_metadata)

if metadata_file.isfile():
return metadata_file.text()
return metadata_file.text()
return ' '

0 comments on commit 55d55fb

Please sign in to comment.