Sort imports

This commit is contained in:
Crystal Melting Dot 2021-02-21 13:43:32 +03:00
parent 784cae145d
commit 7a8990bc74
18 changed files with 77 additions and 57 deletions

View File

@ -1,12 +1,14 @@
from asyncio import sleep
from aiogram import Bot, Dispatcher, executor
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from .middlewares import UserMiddleware, WriteCommandMetric, LoggingMiddleware, ThrottlingMiddleware
from loguru import logger
from tortoise import Tortoise
from tortoise.exceptions import DBConnectionError
from loguru import logger
from asyncio import sleep
from . import config
from . import handlers
from . import config, handlers
from .middlewares import (LoggingMiddleware, ThrottlingMiddleware,
UserMiddleware, WriteCommandMetric)
storage = MemoryStorage()
telegram_bot = Bot(token=config.TELEGRAM_BOT_TOKEN)

View File

@ -1,18 +1,19 @@
from aiogram.types import Message
from typing import Tuple, Any, List
from ..nodes import nodes as all_nodes
from httpx import Response
from aiogram.bot import Bot
from datetime import datetime
from core.coretypes import APINodeInfo
from .helpers import send_api_requests
from .errors import NotEnoughArgs, InvalidPort, LocalhostForbidden
from .validators import BaseValidator, LocalhostValidator
from ..middlewares.throttling import rate_limit
from loguru import logger
from uuid import uuid4
from time import time
from typing import Any, List, Tuple
from uuid import uuid4
from aiogram.bot import Bot
from aiogram.types import Message
from core.coretypes import APINodeInfo
from httpx import Response
from loguru import logger
from ..middlewares.throttling import rate_limit
from ..nodes import nodes as all_nodes
from .errors import InvalidPort, LocalhostForbidden, NotEnoughArgs
from .helpers import send_api_requests
from .validators import BaseValidator, LocalhostValidator
header = "Отчет о проверке хоста:" \
"\n\n— Хост: {target_fq}"\

View File

@ -1,12 +1,12 @@
from aiogram import Dispatcher
from .icmp import ICMPCheckerHandler
from .ipcalc import IPCalcCommandHandler
from .minecraft import MinecraftCheckerHandler
from .start import start_cmd
from .tcp import TCPCheckerHandler
from .web import WebCheckerHandler
from .whois import WhoisCommandHandler
from .icmp import ICMPCheckerHandler
from .tcp import TCPCheckerHandler
from .minecraft import MinecraftCheckerHandler
from .ipcalc import IPCalcCommandHandler
def setup(dp: Dispatcher):

View File

@ -1,9 +1,10 @@
from aiogram.types import Message
from httpx import Response
from core.coretypes import ErrorPayload, ICMPCheckerResponse, ResponseStatus
from ..base import CheckerBaseHandler, NotEnoughArgs, LocalhostForbidden
from ..metrics import push_status_metric
from httpx import Response
from ...middlewares.throttling import rate_limit
from ..base import CheckerBaseHandler, LocalhostForbidden, NotEnoughArgs
from ..metrics import push_status_metric
icmp_help_message = """
Производит проверку хоста по протоколу ICMP.

View File

@ -1,9 +1,10 @@
from aiogram.types import Message
from typing import Union
import ipaddress
from typing import Union
from aiogram.types import Message
from ..base import SimpleCommandHandler, NotEnoughArgs
from ...middlewares.throttling import rate_limit
from ..base import NotEnoughArgs, SimpleCommandHandler
ipcalc_help_message = """
Калькулятор IP подсетей.

View File

@ -1,4 +1,4 @@
from core.coretypes import ResponseStatus, ErrorPayload, MinecraftResponse
from core.coretypes import ErrorPayload, MinecraftResponse, ResponseStatus
from httpx import Response
from ..base import CheckerTargetPortHandler, process_args_for_host_port

View File

@ -1,7 +1,8 @@
from aiogram.types import Message
from ...models.user import User
from ...middlewares.throttling import rate_limit
from ...middlewares.userdata import userdata_required
from ...models.user import User
start_message = """

View File

@ -1,11 +1,13 @@
from typing import Tuple
from aiogram.types import Message
from core.coretypes import ResponseStatus, ErrorPayload, PortResponse
from core.coretypes import ErrorPayload, PortResponse, ResponseStatus
from httpx import Response
from ..base import CheckerTargetPortHandler, NotEnoughArgs, InvalidPort, parse_host_port
from ..metrics import push_status_metric
from ...middlewares.throttling import rate_limit
from ..base import (CheckerTargetPortHandler, InvalidPort, NotEnoughArgs,
parse_host_port)
from ..metrics import push_status_metric
tcp_help_message = """
Производит проверку TCP порта, открыт ли он или нет

View File

@ -1,5 +1,7 @@
from core.coretypes import (HTTP_EMOJI, ErrorPayload, HttpCheckerResponse,
ResponseStatus)
from httpx import Response
from core.coretypes import ResponseStatus, HTTP_EMOJI, HttpCheckerResponse, ErrorPayload
from ..base import CheckerTargetPortHandler, process_args_for_host_port
from ..metrics import push_status_metric

View File

@ -1,15 +1,16 @@
from dataclasses import dataclass
from typing import Optional
from whois import whois, parser
from aiogram.types import Message
from dataclasses import dataclass
from whois_vu.api import WhoisSource
from whois_vu.errors import IncorrectZone, QueryNotMatchRegexp
from ..whois_zones import ZONES
from ..base import SimpleCommandHandler
from ..errors import NotEnoughArgs, LocalhostForbidden
from whois import parser, whois
from ...middlewares.throttling import rate_limit
from ..base import SimpleCommandHandler
from ..errors import LocalhostForbidden, NotEnoughArgs
from ..whois_zones import ZONES
whois_help_message = """
Вернёт информацию о домене.

View File

@ -1,14 +1,16 @@
from httpx import AsyncClient, Timeout, Response
from typing import List, Callable
from core.coretypes import APINode
from ipaddress import ip_address
from contextlib import suppress
from loguru import logger
from aiogram.bot import Bot
from .metrics import push_api_request_status
from ..config import NOTIFICATION_BOT_TOKEN, NOTIFICATION_USERS
from traceback import format_exc
import asyncio
from contextlib import suppress
from ipaddress import ip_address
from traceback import format_exc
from typing import Callable, List
from aiogram.bot import Bot
from core.coretypes import APINode
from httpx import AsyncClient, Response, Timeout
from loguru import logger
from ..config import NOTIFICATION_BOT_TOKEN, NOTIFICATION_USERS
from .metrics import push_api_request_status
async def send_api_request(client: AsyncClient, endpoint: str, data: dict, node: APINode):

View File

@ -1,6 +1,9 @@
from aioinflux import InfluxDBClient
from typing import Dict
from ..config import INFLUX_DB, INFLUX_HOST, INFLUX_PORT, INFLUX_PASSWORD, INFLUX_USERNAME
from aioinflux import InfluxDBClient
from ..config import (INFLUX_DB, INFLUX_HOST, INFLUX_PASSWORD, INFLUX_PORT,
INFLUX_USERNAME)
async def push_metric(measurement, tags: Dict, fields: Dict):

View File

@ -1,6 +1,7 @@
from .errors import LocalhostForbidden
from ipaddress import ip_address
from contextlib import suppress
from ipaddress import ip_address
from .errors import LocalhostForbidden
class BaseValidator:

View File

@ -1,4 +1,4 @@
from .write_command_metric import WriteCommandMetric
from .logging import LoggingMiddleware
from .throttling import ThrottlingMiddleware
from .userdata import UserMiddleware
from .write_command_metric import WriteCommandMetric

View File

@ -1,9 +1,10 @@
import asyncio
from aiogram import Dispatcher, types
from aiogram.dispatcher import DEFAULT_RATE_LIMIT
from aiogram.dispatcher.handler import CancelHandler, current_handler
from aiogram.dispatcher.middlewares import BaseMiddleware
from aiogram.utils.exceptions import Throttled
import asyncio
def rate_limit(func):

View File

@ -1,6 +1,6 @@
from aiogram.dispatcher.handler import current_handler
from aiogram.dispatcher.middlewares import BaseMiddleware
from aiogram.types import Message, CallbackQuery
from aiogram.types import CallbackQuery, Message
from ..models import User

View File

@ -1,5 +1,6 @@
from aiogram.dispatcher.middlewares import BaseMiddleware
from aiogram.types import Message
from ..handlers.metrics import push_metric
from ..models import User, UserCheckRequests

View File

@ -1,6 +1,7 @@
from core.coretypes import APINode
from typing import List
from core.coretypes import APINode
nodes: List[APINode] = [
APINode("http://localhost:8080", "CHANGE_TOKEN_BY_ENV"),
APINode("http://localhost:8080", "CHANGE_TOKEN_BY_ENV"),