def process_params(executor_name): end = False section = Sections.EXECUTOR_PARAMS.format(executor_name) while not end: print( f"The actual {Bcolors.BOLD}{Bcolors.OKBLUE}{executor_name}" f" executor's arguments{Bcolors.ENDC} are: " f"{Bcolors.OKGREEN}{config.instance.options(section)}" f"{Bcolors.ENDC}" ) value = choose_adm("argument") if value == "A": param = click.prompt("Argument name").lower() if param in config.instance.options(section): print(f"{Bcolors.WARNING}The argument {param} already exists" f"{Bcolors.ENDC}") else: value = confirm_prompt("Is mandatory?") config.instance.set(section, param, f"{value}") elif value == "M": param = click.prompt("Argument name").lower() if param not in config.instance.options(section): print(f"{Bcolors.WARNING}There is no {param} argument" f"{Bcolors.ENDC}") else: def_value, param = get_new_name(param, section, "argument") value = confirm_prompt("Is mandatory?", default=def_value) config.instance.set(section, param, f"{value}") elif value == "D": param = click.prompt("Argument name").lower() if param not in config.instance.options(section): print(f"{Bcolors.WARNING}There is no {param} argument" f"{Bcolors.ENDC}") else: config.instance.remove_option(section, param) else: end = True
def process_var_envs(executor_name): end = False section = Sections.EXECUTOR_VARENVS.format(executor_name) while not end: print( f"The actual {Bcolors.BOLD}{Bcolors.OKBLUE}{executor_name}" f" executor's environment variables{Bcolors.ENDC} are:" f" {Bcolors.OKGREEN}{config.instance.options(section)}" f"{Bcolors.ENDC}" ) value = choose_adm("environment variable") if value == "A": env_var = click.prompt("Environment variable name").lower() if env_var in config.instance.options(section): print(f"{Bcolors.WARNING}The environment variable {env_var} " f"already exists{Bcolors.ENDC}") else: value = click.prompt("Environment variable value") config.instance.set(section, env_var, value) elif value == "M": env_var = click.prompt("Environment variable name").lower() if env_var not in config.instance.options(section): print(f"{Bcolors.WARNING}There is no {env_var} environment " f"variable{Bcolors.ENDC}") else: def_value, env_var = get_new_name(env_var, section, "environment variable") value = click.prompt("Environment variable value", default=def_value) config.instance.set(section, env_var, value) elif value == "D": env_var = click.prompt("Environment variable name").lower() if env_var not in config.instance.options(section): print(f"{Bcolors.WARNING}There is no {env_var}" f"environment variable{Bcolors.ENDC}") else: config.instance.remove_option(section, env_var) else: end = True
def process_params(executor_name): end = False if "params" not in config.instance[Sections.AGENT][ Sections.EXECUTORS][executor_name]: config.instance[Sections.AGENT][ Sections.EXECUTORS][executor_name]["params"] = {} section = config.instance[Sections.AGENT][ Sections.EXECUTORS][executor_name].get("params") while not end: print(f"The current {Bcolors.BOLD}{Bcolors.OKBLUE}{executor_name}" f" executor's arguments{Bcolors.ENDC} are: " f"{Bcolors.OKGREEN}{list(section.keys())}" f"{Bcolors.ENDC}") value = choose_adm("argument") if value == "A": param = click.prompt("Argument name").lower() if param in section: print(f"{Bcolors.WARNING}The argument {param} already exists" f"{Bcolors.ENDC}") else: mandatory = confirm_prompt("Is mandatory?") input_type = click.prompt("Type?", type=click.Choice(DATA_TYPE.keys())) input_base_type = DATA_TYPE[input_type].type().base section[param] = { "mandatory": mandatory, "type": input_type, "base": input_base_type } elif value == "M": param = click.prompt("Argument name").lower() if param not in section: print(f"{Bcolors.WARNING}There is no {param} argument" f"{Bcolors.ENDC}") else: def_value, param = get_new_name(param, section, "argument") mandatory = confirm_prompt("Is mandatory?", default=def_value["mandatory"]) input_type = click.prompt("Type?", type=click.Choice(DATA_TYPE.keys()), default=def_value["type"]) input_base_type = DATA_TYPE[input_type].type().base section[param] = { "mandatory": mandatory, "type": input_type, "base": input_base_type } elif value == "D": param = click.prompt("Argument name").lower() if param not in section: print(f"{Bcolors.WARNING}There is no {param} argument" f"{Bcolors.ENDC}") else: section.pop(param) else: end = True
def process_var_envs(executor_name): end = False if "varenvs" not in config.instance[Sections.AGENT][ Sections.EXECUTORS][executor_name]: config.instance[Sections.AGENT][ Sections.EXECUTORS][executor_name]["varenvs"] = {} section = config.instance[Sections.AGENT][ Sections.EXECUTORS][executor_name].get("varenvs") while not end: print(f"The current {Bcolors.BOLD}{Bcolors.OKBLUE}{executor_name}" f" executor's environment variables{Bcolors.ENDC} are:" f" {Bcolors.OKGREEN}{list(section.keys())}" f"{Bcolors.ENDC}") value = choose_adm("environment variable") if value == "A": env_var = click.prompt("Environment variable name").lower() if env_var in section: print(f"{Bcolors.WARNING}The environment variable {env_var} " f"already exists{Bcolors.ENDC}") else: value = click.prompt("Environment variable value") section[env_var] = value elif value == "M": env_var = click.prompt("Environment variable name").lower() if env_var not in section: print(f"{Bcolors.WARNING}There is no {env_var} environment " f"variable{Bcolors.ENDC}") else: def_value, env_var = get_new_name(env_var, section, "environment variable") value = click.prompt("Environment variable value", default=def_value) section[env_var] = value elif value == "D": env_var = click.prompt("Environment variable name").lower() if env_var not in section: print(f"{Bcolors.WARNING}There is no {env_var}" f"environment variable{Bcolors.ENDC}") else: section.pop(env_var) else: end = True