|
|
|
@ -2,16 +2,11 @@
|
|
|
|
|
import argparse |
|
|
|
|
import asyncio |
|
|
|
|
import os |
|
|
|
|
from asyncio import Task |
|
|
|
|
from dataclasses import dataclass |
|
|
|
|
from typing import List, Union |
|
|
|
|
|
|
|
|
|
import aiohttp |
|
|
|
|
from aiohttp.client_exceptions import ClientConnectorError |
|
|
|
|
from loguru import logger |
|
|
|
|
|
|
|
|
|
from app_config import AppConfig |
|
|
|
|
from config_object import ConfigFactory, ConfigObject |
|
|
|
|
from config_object import ConfigFactory |
|
|
|
|
from request_builder import RequestBulder |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -27,7 +22,6 @@ async def get_records_count(rb: RequestBulder) -> int:
|
|
|
|
|
async def custom_wrapper( |
|
|
|
|
config_factory: ConfigFactory, |
|
|
|
|
rb: RequestBulder, |
|
|
|
|
usr: str, |
|
|
|
|
json: dict, |
|
|
|
|
) -> None: |
|
|
|
|
"""Обертка для создания конфигов и их записи.""" |
|
|
|
@ -40,12 +34,12 @@ async def custom_wrapper(
|
|
|
|
|
conf_list = [config_factory.create(host["hostname"]) for host in resp["result"]] |
|
|
|
|
await asyncio.gather(*[c.write() for c in conf_list]) |
|
|
|
|
else: |
|
|
|
|
logger.error(f"Сервер вернул ошибку") |
|
|
|
|
logger.error("Сервер вернул ошибку") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def main(config_path: str) -> None: |
|
|
|
|
async def main(config_path_: str) -> None: |
|
|
|
|
"""Точка входа.""" |
|
|
|
|
cfg: AppConfig = AppConfig(config_path) |
|
|
|
|
cfg: AppConfig = AppConfig(config_path_) |
|
|
|
|
|
|
|
|
|
rb = RequestBulder(cfg) |
|
|
|
|
|
|
|
|
@ -63,7 +57,7 @@ async def main(config_path: str) -> None:
|
|
|
|
|
|
|
|
|
|
conf_factory = ConfigFactory(cfg.template, cfg.path_for_config) |
|
|
|
|
await asyncio.gather( |
|
|
|
|
*[custom_wrapper(conf_factory, rb, "get", jb) for jb in json_boby_list] |
|
|
|
|
*[custom_wrapper(conf_factory, rb, jb) for jb in json_boby_list] |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
await rb.wait() |
|
|
|
|