96 lines
2.1 KiB
Python
Executable File
96 lines
2.1 KiB
Python
Executable File
#!/usr/bin/python
|
|
|
|
from updater import UThread
|
|
from license import LThread
|
|
from checker import CThread
|
|
from cleaner import NThread
|
|
from telegrambot import TGThread
|
|
from webserver import WSThread
|
|
from time import sleep
|
|
from macros import *
|
|
from colors import *
|
|
from threading import Event
|
|
import config, sys, os, asyncio
|
|
|
|
|
|
INFO('╔' + '═'*(len(config.APPNAME) + len(config.VERSION) + 3) + '╗')
|
|
INFO(f"║ {CYAN}{BOLD}{config.APPNAME}{RESET} {config.VERSION} ║")
|
|
INFO('╚' + '═'*(len(config.APPNAME) + len(config.VERSION) + 3) + '╝')
|
|
|
|
if CONF.get('debug'):
|
|
INFO('DEBUG TEST START ' + '*' * 20)
|
|
DEBUG(f"{RESET}{BLACK}*{RED}*{GREEN}*{YELLOW}*{BLUE}*{MAGENTA}*{CYAN}*{WHITE}*")
|
|
DEBUG(f"{RESET}{BOLD}{BLACK}*{RED}*{GREEN}*{YELLOW}*{BLUE}*{MAGENTA}*{CYAN}*{WHITE}*")
|
|
DEBUG(f"{RESET}{BGBLACK}*{BGRED}*{BGGREEN}*{BGYELLOW}*{BGBLUE}*{BGMAGENTA}*{BGCYAN}*{BGWHITE}*")
|
|
INFO('Test message')
|
|
DEBUG('Test message')
|
|
SUCC('Test message')
|
|
WARN('Test message')
|
|
ERR('Test message')
|
|
CRIT('Test message')
|
|
INFO('DEBUG TEST END ' + '*' * 22 + RESET)
|
|
|
|
|
|
eupdate = Event()
|
|
estop = Event()
|
|
|
|
lt = LThread(eupdate)
|
|
lt.daemon = True
|
|
lt.start()
|
|
|
|
wt = WSThread(eupdate)
|
|
wt.daemon = True
|
|
wt.start()
|
|
|
|
ct = CThread(eupdate)
|
|
ct.daemon = True
|
|
ct.start()
|
|
|
|
nt = NThread(eupdate)
|
|
nt.daemon = True
|
|
nt.start()
|
|
|
|
tt = TGThread(eupdate, estop)
|
|
tt.daemon = True
|
|
tt.start()
|
|
|
|
ut = UThread()
|
|
ut.daemon = True
|
|
ut.start()
|
|
|
|
updated = False
|
|
|
|
try:
|
|
while 1:
|
|
if lt.is_alive() and wt.is_alive() and ct.is_alive() and tt.is_alive() and ut.is_alive() and nt.is_alive():
|
|
sleep(1)
|
|
elif lt.is_alive() and wt.is_alive() and ct.is_alive() and tt.is_alive() and nt.is_alive():
|
|
eupdate.set()
|
|
if lt.is_alive(): lt.join()
|
|
if wt.is_alive(): wt.join()
|
|
if ct.is_alive(): ct.join()
|
|
if nt.is_alive(): nt.join()
|
|
if tt.is_alive(): tt.join()
|
|
updated = True
|
|
SUCC('Program updated, reboot!')
|
|
break
|
|
else:
|
|
estop.set()
|
|
sleep(1)
|
|
CRIT('Program broken.')
|
|
os._exit(3)
|
|
except KeyboardInterrupt:
|
|
sys.stdout.flush()
|
|
print('\r', end='')
|
|
estop.set()
|
|
sleep(1)
|
|
CRIT('STOP')
|
|
except Exception as e:
|
|
CRIT(str(e))
|
|
estop.set()
|
|
sleep(1)
|
|
os._exit(1)
|
|
|
|
if updated:
|
|
os.execl(sys.argv[0], *sys.argv)
|