-
Notifications
You must be signed in to change notification settings - Fork 3
/
run.py
64 lines (50 loc) · 2.42 KB
/
run.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
""" The test for the API """
import asyncio
import logging
import sys
import time
from time import sleep
from astrolive.client import AstroLive
from astrolive.errors import AstroLiveError
_LOGGER = logging.getLogger(__name__)
logging.basicConfig(
stream=sys.stdout,
level=logging.INFO,
format="%(asctime)s %(levelname)s (%(threadName)s) [%(funcName)s] %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
COLOR_BLACK = "1;30"
COLOR_RED = "1;31"
COLOR_GREEN = "1;32"
COLOR_BROWN = "1;33"
COLOR_BLUE = "1;34"
COLOR_PURPLE = "1;35"
COLOR_CYAN = "1;36"
BANNER = (
"\n░█████╗░░██████╗████████╗██████╗░░█████╗░██╗░░░░░██╗██╗░░░██╗███████╗\n"
+ "██╔══██╗██╔════╝╚══██╔══╝██╔══██╗██╔══██╗██║░░░░░██║██║░░░██║██╔════╝\n"
+ "███████║╚█████╗░░░░██║░░░██████╔╝██║░░██║██║░░░░░██║╚██╗░██╔╝█████╗░░\n"
+ "██╔══██║░╚═══██╗░░░██║░░░██╔══██╗██║░░██║██║░░░░░██║░╚████╔╝░██╔══╝░░\n"
+ "██║░░██║██████╔╝░░░██║░░░██║░░██║╚█████╔╝███████╗██║░░╚██╔╝░░███████╗\n"
+ "╚═╝░░╚═╝╚═════╝░░░░╚═╝░░░╚═╝░░╚═╝░╚════╝░╚══════╝╚═╝░░░╚═╝░░░╚══════╝\n"
)
def esc(code):
return f"\033[{code}m"
async def main() -> None:
"""AstroLive Main Thread."""
print(f"{esc(COLOR_RED)}{BANNER}{esc('0')}")
al = AstroLive()
start = time.time()
await al.link_observatory()
await al.start_looper()
try:
while True:
await al.start_monitoring()
await al.health_check()
sleep(30)
await al.link_observatory()
except AstroLiveError as err:
_LOGGER.error(err)
end = time.time()
_LOGGER.info(f"Execution time: %s seconds", end - start)
asyncio.run(main())