def load_secure_var(cvar): if encrypted_config_file_exists(cvar): password = in_memory_config_map.get("password").value if password is not None: cvar.value = decrypt_config_value(cvar, password) return True return False
async def save_to_yml(yml_path: str, cm: Dict[str, ConfigVar]): """ Write current config saved a single config map into each a single yml file """ try: with open(yml_path) as stream: data = yaml_parser.load(stream) or {} for key in cm: cvar = cm.get(key) if cvar.is_secure: if cvar.value is not None and not encrypted_config_file_exists( cvar): from hummingbot.client.config.in_memory_config_map import in_memory_config_map password = in_memory_config_map.get("password").value encrypt_n_save_config_value(cvar, password) if key in data: data.pop(key) elif type(cvar.value) == Decimal: data[key] = float(cvar.value) else: data[key] = cvar.value with open(yml_path, "w+") as outfile: yaml_parser.dump(data, outfile) except Exception as e: logging.getLogger().error("Error writing configs: %s" % (str(e), ), exc_info=True)
async def _encrypt_n_save_config_value(self, # type: HummingbotApplication cvar: ConfigVar): if in_memory_config_map.get("password").value is None: in_memory_config_map.get("password").value = await self._one_password_config() password = in_memory_config_map.get("password").value if encrypted_config_file_exists(cvar): unlink(get_encrypted_config_path(cvar)) encrypt_n_save_config_value(cvar, password)