コード例 #1
0
def migrate_global_config() -> List[str]:
    global celo_address

    logging.getLogger().info("\nMigrating the global config...")
    global_config_path = CONF_DIR_PATH / "conf_global.yml"
    errors = []
    if global_config_path.exists():
        with open(str(global_config_path), "r") as f:
            data = yaml.safe_load(f)
        del data["template_version"]
        client_config_map = ClientConfigAdapter(ClientConfigMap())
        _migrate_global_config_modes(client_config_map, data)
        data.pop("kraken_api_tier", None)
        data.pop("key_file_path", None)
        celo_address = data.pop("celo_address", None)
        keys = list(data.keys())
        for key in keys:
            if key in client_config_map.keys():
                _migrate_global_config_field(client_config_map, data, key)
        for key in data:
            logging.getLogger().warning(f"Global ConfigVar {key} was not migrated.")
        errors.extend(client_config_map.validate_model())
        if len(errors) == 0:
            save_to_yml(CLIENT_CONFIG_PATH, client_config_map)
            global_config_path.unlink()
            logging.getLogger().info("\nSuccessfully migrated the global config.")
        else:
            errors = [f"client_config_map - {e}" for e in errors]
            logging.getLogger().error(f"The migration of the global config map failed with errors: {errors}")
    return errors
コード例 #2
0
 async def prompt_for_model_config(
     self,  # type: HummingbotApplication
     config_map: ClientConfigAdapter,
 ):
     for key in config_map.keys():
         client_data = config_map.get_client_data(key)
         if (
             client_data is not None
             and (client_data.prompt_on_new or config_map.is_required(key))
         ):
             await self.prompt_a_config(config_map, key)
             if self.app.to_stop_config:
                 break
コード例 #3
0
 def build_config_map(cm: ClientConfigAdapter, cs: Dict):
     """This routine can be used in the create command, with slight modifications."""
     for key in cm.keys():
         client_data = cm.get_client_data(key)
         if client_data is not None and client_data.prompt_on_new:
             self.assertIsInstance(client_data.prompt(cm), str)
             if key == "execution_timeframe_model":
                 setattr(cm, key,
                         "daily_between_times")  # simulate user input
             else:
                 setattr(cm, key, cs[key])
             new_value = getattr(cm, key)
             if isinstance(new_value, ClientConfigAdapter):
                 build_config_map(new_value, cs[key])