added init monitor for shared logic
This commit is contained in:
1 parent
6025393ad4
commit
1f36a62d34
1 file changed
+19
-2
@@ -8,12 +8,18 @@ from aioproxies import AioProxies
|
||||
from curl_cffi.requests import AsyncSession
|
||||
from motor.motor_asyncio import AsyncIOMotorCollection
|
||||
|
||||
from aioproxies import AioProxies
|
||||
from monitor_utils.constants import (
|
||||
EXPECTED_TASK_ERRORS,
|
||||
FLAG_WEBHOOK_MAP,
|
||||
BUCKET_WEBHOOK_MAP,
|
||||
)
|
||||
from monitor_utils.config import get_config, is_production, DevelopmentMode
|
||||
from monitor_utils.config import (
|
||||
get_config,
|
||||
is_production,
|
||||
set_logger_levels,
|
||||
DevelopmentMode,
|
||||
)
|
||||
from monitor_utils.models import (
|
||||
Product,
|
||||
ProductMetadata,
|
||||
@@ -27,9 +33,20 @@ from monitor_utils.database import get_collection
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def init_monitor(
|
||||
monitor_name: str, development_mode: DevelopmentMode
|
||||
) -> tuple[list[str], AsyncIOMotorCollection, AioProxies]:
|
||||
set_logger_levels()
|
||||
category_names, _, collection = setup_config(
|
||||
monitor_name=monitor_name, development_mode=development_mode
|
||||
)
|
||||
proxies = AioProxies.from_file("proxies.txt")
|
||||
return category_names, collection, proxies
|
||||
|
||||
|
||||
def setup_config(
|
||||
monitor_name: str, development_mode: DevelopmentMode
|
||||
) -> tuple[list[str], dict, AsyncIOMotorCollection]:
|
||||
) -> tuple[list[str], dict[int], AsyncIOMotorCollection]:
|
||||
use_production = is_production(development_mode)
|
||||
config, _ = get_config(
|
||||
monitor_name=monitor_name,
|
||||
|
||||
Reference in new issue
Block a user