Skip to content

Commit 55d55fb

Browse files
author
afabiani
committed
- patch: boolean string properties checks are wrong on "output_file_parameter"
1 parent c3f64e3 commit 55d55fb

File tree

3 files changed

+24
-25
lines changed

3 files changed

+24
-25
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
setup(
3535
name = "wps-remote",
36-
version = "2.14.3",
36+
version = "2.14.4",
3737
author = "GeoServer Developers",
3838
author_email = "geoserver-devel@lists.sourceforge.net",
3939
description = "A library that allows users to publish their executables as GeoServer WPS Processes through the XMPP protocol",

src/wpsremote/computational_job_input_action_create_json_file.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def __init__(self, input_ref, json_filepath, json_path_expr=None, json_schema=No
2121
self._input_ref = input_ref
2222
self._json_filepath = json_filepath if isinstance(json_filepath, path.path) else path.path(json_filepath)
2323

24-
# Python-like expression to access json data in memory.
24+
# Python-like expression to access json data in memory.
2525
# 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
2626
self._json_path_expr = json_path_expr
2727
self.json_files_created = []
@@ -30,7 +30,7 @@ def __init__(self, input_ref, json_filepath, json_path_expr=None, json_schema=No
3030
self._json_schema = json.loads(json_schema.text())
3131
else:
3232
self._json_schema = json.loads(json_schema)
33-
33+
3434

3535
def set_inputs(self, inputs):
3636
#for par_name in self._input_refs:
@@ -64,7 +64,7 @@ def validate_json(self, json_text):
6464
msg = "Invalid json for asset: " + str(ex)
6565
logger.fatal(msg)
6666
raise ex
67-
67+
6868
def create_json_file(self, json_text):
6969
json_filepath = self._extract_id_from_json(json_text)
7070
#json_filepath.write_text( json_text )
@@ -75,7 +75,7 @@ def create_json_file(self, json_text):
7575

7676

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

src/wpsremote/output_file_parameter.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# #
2121
# ############################################################################################################# #
2222
class OutputFileParameter(object):
23-
23+
2424
def __init__(self, par_name, d, template_vars_for_param_types=None, wps_execution_shared_dir=None, uploader=None):
2525
#{"type": "string", "description": "xml OAA output file", "filepath" : "%workdir\\\\output_file.xml" }
2626
self._name=par_name
@@ -47,7 +47,7 @@ def __init__(self, par_name, d, template_vars_for_param_types=None, wps_executio
4747
for var, val in template_vars_for_param_types.items():
4848
if var in v:
4949
v=v.replace("%" + var,val)
50-
50+
5151
setattr(self, "_" + k, v)
5252

5353
self._filepath = path.path(self._filepath)
@@ -66,7 +66,7 @@ def as_json_string(self):
6666
return json.dumps(res)
6767

6868
def get_value(self):
69-
if self._backup_on_wps_execution_shared_dir != None and self._backup_on_wps_execution_shared_dir and self._wps_execution_shared_dir != None:
69+
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:
7070
unique_dirname = str(uuid.uuid4())
7171
bkp_dir = path.path(self._wps_execution_shared_dir + "/" + unique_dirname)
7272
bkp_dir.makedirs()
@@ -76,7 +76,7 @@ def get_value(self):
7676
dst = path.path(dst)
7777

7878
return dst.text()
79-
elif self._upload_data != None and self._upload_data and self._uploader != None:
79+
elif self._upload_data != None and self._upload_data.lower() is "true" and self._uploader != None:
8080
unique_dirname = str(uuid.uuid4())
8181
bkp_dir = path.path(tempfile.gettempdir() + '/' + unique_dirname)
8282
bkp_dir.makedirs()
@@ -107,7 +107,7 @@ def get_output_mime_type(self):
107107
return self._output_mime_type
108108

109109
def is_publish_as_layer(self):
110-
return (self._publish_as_layer != None and self._publish_as_layer == "true")
110+
return (self._publish_as_layer != None and self._publish_as_layer.lower() is "true")
111111

112112
def get_publish_layer_name(self):
113113
return self._publish_layer_name
@@ -123,7 +123,7 @@ def get_metadata(self):
123123
metadata_file = path.path(self._publish_metadata)
124124

125125
if metadata_file.isfile():
126-
return metadata_file.text()
126+
return metadata_file.text()
127127
return ' '
128128

129129
# ############################################################################################################# #
@@ -132,7 +132,7 @@ def get_metadata(self):
132132
# #
133133
# ############################################################################################################# #
134134
class RawFileParameter(object):
135-
135+
136136
def __init__(self, par_name, d, template_vars_for_param_types=None, wps_execution_shared_dir=None, uploader=None):
137137
#{"type": "string", "description": "xml OAA output file", "filepath" : "%workdir\\\\output_file.xml" }
138138
self._name=par_name
@@ -159,7 +159,7 @@ def __init__(self, par_name, d, template_vars_for_param_types=None, wps_executio
159159
for var, val in template_vars_for_param_types.items():
160160
if var in v:
161161
v=v.replace("%" + var,val)
162-
162+
163163
setattr(self, "_" + k, v)
164164

165165
self._filepath = path.path(self._filepath)
@@ -178,7 +178,7 @@ def as_json_string(self):
178178
return json.dumps(res)
179179

180180
def get_value(self):
181-
if self._backup_on_wps_execution_shared_dir != None and self._backup_on_wps_execution_shared_dir and self._wps_execution_shared_dir != None:
181+
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:
182182
unique_dirname = str(uuid.uuid4())
183183
bkp_dir = path.path(self._wps_execution_shared_dir + "/" + unique_dirname)
184184
bkp_dir.makedirs()
@@ -188,9 +188,9 @@ def get_value(self):
188188
dst = path.path(dst)
189189

190190
return dst
191-
elif self._upload_data != None and self._upload_data and self._uploader != None:
191+
elif self._upload_data != None and self._upload_data.lower() is "true" and self._uploader != None:
192192
unique_dirname = str(uuid.uuid4())
193-
193+
194194
if self._upload_data_root:
195195
unique_dirname = self._upload_data_root + '/' + unique_dirname
196196
src_path = os.path.abspath(os.path.join(self._filepath.abspath(), os.pardir))
@@ -215,7 +215,7 @@ def get_output_mime_type(self):
215215
return self._output_mime_type
216216

217217
def is_publish_as_layer(self):
218-
return (self._publish_as_layer != None and self._publish_as_layer == "true")
218+
return (self._publish_as_layer != None and self._publish_as_layer.lower() is "true")
219219

220220
def get_publish_layer_name(self):
221221
return self._publish_layer_name
@@ -231,7 +231,7 @@ def get_metadata(self):
231231
metadata_file = path.path(self._publish_metadata)
232232

233233
if metadata_file.isfile():
234-
return metadata_file.text()
234+
return metadata_file.text()
235235
return ' '
236236

237237

@@ -241,7 +241,7 @@ def get_metadata(self):
241241
# #
242242
# ############################################################################################################# #
243243
class OWCFileParameter(object):
244-
244+
245245
def __init__(self, par_name, d, parameters_types_defs, template_vars_for_param_types=None, wps_execution_shared_dir=None, uploader=None):
246246
#{"type": "string", "description": "xml OAA output file", "filepath" : "%workdir\\\\output_file.xml" }
247247
self._name=par_name
@@ -267,7 +267,7 @@ def __init__(self, par_name, d, parameters_types_defs, template_vars_for_param_t
267267
for var, val in template_vars_for_param_types.items():
268268
if var in v:
269269
v=v.replace("%" + var,val)
270-
270+
271271
setattr(self, "_" + k, v)
272272

273273
self._files_to_publish = ''
@@ -307,7 +307,7 @@ def as_json_string(self):
307307
return json.dumps(res)
308308

309309
def get_value(self):
310-
if self._backup_on_wps_execution_shared_dir != None and self._backup_on_wps_execution_shared_dir and self._wps_execution_shared_dir != None:
310+
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:
311311
unique_dirname = str(uuid.uuid4())
312312
bkp_dir = path.path(self._wps_execution_shared_dir + "/" + unique_dirname)
313313
bkp_dir.makedirs()
@@ -326,7 +326,7 @@ def get_value(self):
326326
files_to_publish = files_to_publish + dst.abspath()
327327

328328
return files_to_publish
329-
elif self._upload_data != None and self._upload_data and self._uploader != None:
329+
elif self._upload_data != None and self._upload_data.lower() is "true" and self._uploader != None:
330330
unique_dirname = str(uuid.uuid4())
331331
bkp_dir = path.path(tempfile.gettempdir() + '/' + unique_dirname)
332332
bkp_dir.makedirs()
@@ -366,7 +366,7 @@ def get_output_mime_type(self):
366366
return self._output_mime_type
367367

368368
def is_publish_as_layer(self):
369-
return (self._publish_as_layer != None and self._publish_as_layer == "true")
369+
return (self._publish_as_layer != None and self._publish_as_layer.lower() is "true")
370370

371371
def get_publish_layer_name(self):
372372
return self._publish_layer_name
@@ -382,5 +382,5 @@ def get_metadata(self):
382382
metadata_file = path.path(self._publish_metadata)
383383

384384
if metadata_file.isfile():
385-
return metadata_file.text()
385+
return metadata_file.text()
386386
return ' '

0 commit comments

Comments
 (0)