def set_term_options(**kwargs): r""" Set the global term_options. If the global term_options is not None, gen_exit_function() will call terminate_descendants(). Description of arguments(): kwargs Supported keyword options follow: term_requests Requests to terminate specified descendants of this program. The following values for term_requests are supported: children Terminate the direct children of this program. descendants Terminate all descendants of this program. <dictionary> A dictionary with support for the following keys: pgm_names A list of program names which will be used to identify which descendant processes should be terminated. """ global term_options # Validation: arg_names = list(kwargs.keys()) gv.valid_list(arg_names, ['term_requests']) if type(kwargs['term_requests']) is dict: keys = list(kwargs['term_requests'].keys()) gv.valid_list(keys, ['pgm_names']) else: gv.valid_value(kwargs['term_requests'], ['children', 'descendants']) term_options = kwargs
def required_plug_in(required_plug_in_names, plug_in_dir_paths=None): r""" Determine whether the required_plug_in_names are in plug_in_dir_paths, construct an error_message and call gv.process_error_message(error_message). In addition, for each plug-in in required_plug_in_names, set the global plug-in variables. This is useful for callers who then want to validate certain values from other plug-ins. Example call: required_plug_in(required_plug_in_names) Description of argument(s): required_plug_in_names A list of plug_in names that the caller requires (e.g. ['OS_Console']). plug_in_dir_paths A string which is a colon-delimited list of plug-ins specified by the user (e.g. DB_Logging:FFDC:OS_Console:Perf). Path values (e.g. "/home/robot/dir1") will be stripped from this list to do the analysis. Default value is the AUTOGUI_PLUG_IN_DIR_PATHS or <PLUG_VAR_PREFIX>_PLUG_IN_DIR_PATHS environment variable. """ # Calculate default value for plug_in_dir_paths. plug_in_dir_paths = gm.dft( plug_in_dir_paths, os.environ.get( 'AUTOGUI_PLUG_IN_DIR_PATHS', os.environ.get(PLUG_VAR_PREFIX + "_PLUG_IN_DIR_PATHS", ""))) # Convert plug_in_dir_paths to a list of base names. plug_in_dir_paths = \ list(filter(None, map(os.path.basename, plug_in_dir_paths.split(":")))) error_message = gv.valid_list(plug_in_dir_paths, required_values=required_plug_in_names) if error_message: return gv.process_error_message(error_message) for plug_in_package_name in required_plug_in_names: get_plug_vars(general=False, plug_in_package_name=plug_in_package_name)
def valid_list(var_name, *args, **kwargs): var_value, args, kwargs = valid_init(var_name, *args, **kwargs) error_message = \ gv.valid_list(var_value, *args, var_name=var_name, **kwargs) process_error_message(error_message)