From 55d55fb8554afbf4a49effe5cf90cf674baa3c5f Mon Sep 17 00:00:00 2001 From: afabiani Date: Thu, 27 Sep 2018 13:03:51 +0200 Subject: [PATCH] - patch: boolean string properties checks are wrong on "output_file_parameter" --- setup.py | 2 +- ...ional_job_input_action_create_json_file.py | 9 ++--- src/wpsremote/output_file_parameter.py | 38 +++++++++---------- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/setup.py b/setup.py index aef96ed..7361c58 100644 --- a/setup.py +++ b/setup.py @@ -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", diff --git a/src/wpsremote/computational_job_input_action_create_json_file.py b/src/wpsremote/computational_job_input_action_create_json_file.py index 0713e6d..15321d5 100644 --- a/src/wpsremote/computational_job_input_action_create_json_file.py +++ b/src/wpsremote/computational_job_input_action_create_json_file.py @@ -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 = [] @@ -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: @@ -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 ) @@ -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 @@ -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] - diff --git a/src/wpsremote/output_file_parameter.py b/src/wpsremote/output_file_parameter.py index 56ffd6e..2397c5d 100644 --- a/src/wpsremote/output_file_parameter.py +++ b/src/wpsremote/output_file_parameter.py @@ -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 @@ -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) @@ -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() @@ -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() @@ -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 @@ -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 ' ' # ############################################################################################################# # @@ -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 @@ -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) @@ -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() @@ -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)) @@ -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 @@ -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 ' ' @@ -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 @@ -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 = '' @@ -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() @@ -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() @@ -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 @@ -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 ' '