Skip to content

Commit 0e80cd6

Browse files
authored
Merge pull request #60 from eodms-sgdot/development
Development
2 parents b83208d + c395d60 commit 0e80cd6

File tree

4 files changed

+97
-1856
lines changed

4 files changed

+97
-1856
lines changed

eodms_cli.py

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
__license__ = 'MIT License'
1818
__description__ = 'Script used to search, order and download imagery from ' \
1919
'the EODMS using the REST API (RAPI) service.'
20-
__version__ = '3.6.1'
20+
__version__ = '3.6.2'
2121
__maintainer__ = 'Kevin Ballantyne'
2222
__email__ = 'eodms-sgdot@nrcan-rncan.gc.ca'
2323

@@ -981,17 +981,33 @@ def ask_param(param):
981981
labels = [c.get('label') for c in param.const_vals
982982
if c.get('active')]
983983
multiple = param.multiple
984-
choice_idx = ask_item(param.label, labels, 'param',
984+
choice = ask_item(param.label, labels, 'param',
985985
multiple=multiple,
986986
default=default_val,
987987
def_msg=default_str)
988-
choice = [labels[int(idx) - 1] for idx in choice_idx]
989988
else:
990989
msg = f'Enter the "{param.get_label()}"'
991990
choice = self.get_input(msg, required=False,
992991
default=default)
993992

994-
param.set_value(choice)
993+
# print(f"choice: {choice}")
994+
995+
val_check = param.set_value(choice)
996+
997+
if not val_check:
998+
err_msg = f"An invalid value has been entered. The value has " \
999+
f"to be of type '{param.get_data_type()}'"
1000+
self.eod.print_msg(err_msg, heading='error')
1001+
self.logger.error(err_msg)
1002+
self.eod.exit_cli(1)
1003+
1004+
if param.const_vals:
1005+
# print(f"param.const_vals: {param.const_vals}")
1006+
# print(f"labels: {labels}")
1007+
# print(f"choice_idx: {choice}")
1008+
choice = [labels[int(idx) - 1] for idx in choice]
1009+
1010+
# print(f"choice: {choice}")
9951011

9961012
# if (param.data_type == bool and choice) or ():
9971013
if param.get_value():
@@ -1058,6 +1074,14 @@ def ask_item(item_name, item_list, item_type='runner', multiple=False,
10581074
if choice:
10591075
choice = str(choice).split(',')
10601076

1077+
for c in choice:
1078+
if not c.isdigit() or int(c) > len(item_list) \
1079+
or int(c) <= 0:
1080+
err_msg = "An invalid value has been entered."
1081+
self.eod.print_msg(err_msg, heading='error')
1082+
self.logger.error(err_msg)
1083+
self.eod.exit_cli(1)
1084+
10611085
return choice
10621086

10631087
self.print_header("Enter SAR Toolbox Information")
@@ -1073,7 +1097,7 @@ def ask_item(item_name, item_list, item_type='runner', multiple=False,
10731097
def_msg = param.get_default(as_listidx=True, include_label=True)
10741098
default = param.get_default(as_listidx=True)
10751099
labels = [c.get('label') for c in param.const_vals]
1076-
print(f"labels: {labels}")
1100+
# print(f"labels: {labels}")
10771101
multiple = param.multiple
10781102
choice_idx = ask_item(param.label, labels, 'param',
10791103
default=default,

0 commit comments

Comments
 (0)