Пример #1
0
def __verify_deprecated_env_variables(config):
    env_var_duplicated = "IMPORTANT: If you are using \"{}\" environment variable, \"{}\" value will be ignored."
    env_var_deprecated = "IMPORTANT: \"{}\" environment variable is deprecated on this version, use \"{}\" instead."

    if os.getenv(CONFIGMAP_FILE_ENVIRONMENT_LEGACY) is not None:
        if os.getenv(CONFIGMAP_FILE_ENVIRONMENT) is not None:
            msg = env_var_duplicated.format(CONFIGMAP_FILE_ENVIRONMENT,
                                            CONFIGMAP_FILE_ENVIRONMENT_LEGACY)
        else:
            msg = env_var_deprecated.format(CONFIGMAP_FILE_ENVIRONMENT_LEGACY,
                                            CONFIGMAP_FILE_ENVIRONMENT)
        try:
            if config.pyms.config.DEBUG:
                msg = utils.colored_text(msg, utils.Colors.BRIGHT_YELLOW, True)
        except AttrDoesNotExistException:
            pass
        logger.warning(msg)

    if os.getenv(CRYPT_FILE_KEY_ENVIRONMENT_LEGACY) is not None:
        if os.getenv(CRYPT_FILE_KEY_ENVIRONMENT) is not None:
            msg = env_var_duplicated.format(CRYPT_FILE_KEY_ENVIRONMENT,
                                            CRYPT_FILE_KEY_ENVIRONMENT_LEGACY)
        else:
            msg = env_var_deprecated.format(CRYPT_FILE_KEY_ENVIRONMENT_LEGACY,
                                            CRYPT_FILE_KEY_ENVIRONMENT)
        try:
            if config.pyms.config.DEBUG:
                msg = utils.colored_text(msg, utils.Colors.BRIGHT_YELLOW, True)
        except AttrDoesNotExistException:
            pass
        logger.warning(msg)
Пример #2
0
 def yes_no_input(self, msg=""):  # pragma: no cover
     answer = input(  # nosec
         utils.colored_text(f'{msg}{"?" if not msg.endswith("?") else ""} [Y/n] :', utils.Colors.BLUE, True)
     )
     try:
         return strtobool(answer)
     except ValueError:
         self.print_error('Invalid input, Please answer with a "Y" or "n"')
         self.yes_no_input(msg)
Пример #3
0
 def print_error(msg=""):  # pragma: no cover
     print(utils.colored_text(msg, utils.Colors.BRIGHT_RED, True))
Пример #4
0
 def print_ok(msg=""):
     print(utils.colored_text(msg, utils.Colors.BRIGHT_GREEN, True))