17
17
__license__ = 'MIT License'
18
18
__description__ = 'Script used to search, order and download imagery from ' \
19
19
'the EODMS using the REST API (RAPI) service.'
20
- __version__ = '3.6.1 '
20
+ __version__ = '3.6.2 '
21
21
__maintainer__ = 'Kevin Ballantyne'
22
22
__email__ = 'eodms-sgdot@nrcan-rncan.gc.ca'
23
23
@@ -981,17 +981,33 @@ def ask_param(param):
981
981
labels = [c .get ('label' ) for c in param .const_vals
982
982
if c .get ('active' )]
983
983
multiple = param .multiple
984
- choice_idx = ask_item (param .label , labels , 'param' ,
984
+ choice = ask_item (param .label , labels , 'param' ,
985
985
multiple = multiple ,
986
986
default = default_val ,
987
987
def_msg = default_str )
988
- choice = [labels [int (idx ) - 1 ] for idx in choice_idx ]
989
988
else :
990
989
msg = f'Enter the "{ param .get_label ()} "'
991
990
choice = self .get_input (msg , required = False ,
992
991
default = default )
993
992
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}")
995
1011
996
1012
# if (param.data_type == bool and choice) or ():
997
1013
if param .get_value ():
@@ -1058,6 +1074,14 @@ def ask_item(item_name, item_list, item_type='runner', multiple=False,
1058
1074
if choice :
1059
1075
choice = str (choice ).split (',' )
1060
1076
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
+
1061
1085
return choice
1062
1086
1063
1087
self .print_header ("Enter SAR Toolbox Information" )
@@ -1073,7 +1097,7 @@ def ask_item(item_name, item_list, item_type='runner', multiple=False,
1073
1097
def_msg = param .get_default (as_listidx = True , include_label = True )
1074
1098
default = param .get_default (as_listidx = True )
1075
1099
labels = [c .get ('label' ) for c in param .const_vals ]
1076
- print (f"labels: { labels } " )
1100
+ # print(f"labels: {labels}")
1077
1101
multiple = param .multiple
1078
1102
choice_idx = ask_item (param .label , labels , 'param' ,
1079
1103
default = default ,
0 commit comments