-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.py
48 lines (35 loc) · 1.11 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import asyncio
import inspect
from config import ENDLESS_MENU
from loguru import logger
from greeting import greeting_message
from modules.provider import get_module
async def run_option(methods: list):
for method in methods:
if callable(method):
if inspect.iscoroutinefunction(method):
await method()
else:
method()
else:
print(f"Object {method} is not callable")
async def startup():
try:
while True:
greeting_message()
module = input("Module: ")
if not module.isdigit():
logger.error("Wrong module format. It should be number")
if module == "0":
logger.info("Shutting down. Bye!")
else:
logger.info(f"Start module {module}")
worker = get_module(module)
if not worker:
logger.error("Wrong module number")
await run_option(worker)
if not ENDLESS_MENU:
exit()
except Exception as e:
logger.error(e)
asyncio.run(startup())