You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.8 KiB

# Здесь ищём порты и обновляем все сайты
from time import sleep
from db import *
from network import *
# Логирование ошибок
import logging
# Просто логирование
from icecream import ic
ic.disable() # Отключение логирования
def update_demon(serv_port):
while True:
try:
# Собираем порты
ports = port_check(serv_port)
conf = read()
conf["ports"] = ports
write(conf)
# Перебираем всех клиентов
for port in ports:
try:
# Проверяем у клиента его сайты и сравниваем
raw = client(port, "check_all").split("<>")
dest = [] # Приводим к виду ["just.j et", "2"]
for i in raw:
dest.append(i.split("_"))
# Проверяем наши сайты
raw = client(8001, "check_all", '127.0.0.1').split("<>")
our = [] # Приводим к виду ["just.jet", "2"]
for i in raw:
our.append(i.split("_"))
# Сравниваем
for i in range(len(dest)):
el = dest[i][0]
ver = dest[i][1]
# Проверяем есть ли у нас такое
found = False
for check in our:
if check[0] == el:
# Сверяем версии
if check[1] >= ver:
ic("Ver_ok: ", el)
pass
else:
# Если версия новее
ic("Ver_new: ", el)
8 months ago
http_port = client(port, f"is_{el}")
client(http_port, f"get_{el}")
found = True
break # Если нашли - выходим
if not found:
ic("Not_found: ", el)
http_port = client(port, f"is_{el}")
client(http_port, f"get_{el}")
except:
pass
except Exception as e:
ic("UPDATER FALLED")
logging.critical(e, exc_info=True)