попытка в змейку)
This commit is contained in:
parent
4fed6b897c
commit
21c1a68ec1
91
hlna.py
91
hlna.py
@ -12,6 +12,7 @@ import tarfile
|
||||
import logging
|
||||
import datetime
|
||||
import requests
|
||||
import threading
|
||||
import subprocess
|
||||
|
||||
import yaml
|
||||
@ -167,28 +168,29 @@ def print_line(*text, flag="", sep=" ", end="\n"):
|
||||
|
||||
|
||||
def zmeyuka(stdscr, func):
|
||||
print_line(func)
|
||||
curses.curs_set(0)
|
||||
stdscr.nodelay(1)
|
||||
|
||||
x = 0
|
||||
y = 0
|
||||
|
||||
stdscr.addstr(y, x, "⠋")
|
||||
stdscr.refresh()
|
||||
|
||||
def nachalo_stroki():
|
||||
nonlocal x, y
|
||||
while True:
|
||||
stdscr.addstr(0, 0, "⠋", curses.A_REVERSE)
|
||||
stdscr.refresh()
|
||||
time.sleep(0.1)
|
||||
stdscr.addstr(y, x, " ")
|
||||
x += 1
|
||||
if x > curses.COLS - 1:
|
||||
x = 0
|
||||
y +=1
|
||||
stdscr.addstr(y, x, "⠋")
|
||||
stdscr.refresh()
|
||||
while func.do_run:
|
||||
zmejka = '⠇⠋⠙⠸⠴⠦'
|
||||
for i in range(len(zmejka)):
|
||||
print('\r' + zmejka[i], end="", flush=True)
|
||||
time.sleep(0.25)
|
||||
th = threading.Thread(target=func)
|
||||
th.start()
|
||||
# Запуск потока со змеюкой
|
||||
zmeyuka_thread = threading.Thread(target=nachalo_stroki)
|
||||
zmeyuka_thread.start()
|
||||
# Ожидаем завершение функции
|
||||
th.join()
|
||||
# Убираем змеюку
|
||||
zmeyuka_thread.do_run = False
|
||||
zmeyuka_thread.join()
|
||||
|
||||
curses.curs_set(1)
|
||||
stdscr.nodelay(0)
|
||||
|
||||
|
||||
def check_int(number=""):
|
||||
@ -743,32 +745,35 @@ def modupdate(g, m, id_mod, dir_mod_ark):
|
||||
g = g.lower()
|
||||
if g == "ark":
|
||||
print_line(f"Проверяем обновление мода {id_mod}", flag="CYAN")
|
||||
with open(os.path.join(dir_mod_ark, f"appworkshop_346110.acf"), "r") as f:
|
||||
content = f.readlines()
|
||||
content = "".join(content)
|
||||
locale_date = ""
|
||||
for line in content.splitlines():
|
||||
if '\t"WorkshopItemsInstalled"' in line:
|
||||
for line in content.splitlines():
|
||||
if f'\t\t"timeupdated"' in line:
|
||||
locale_date = line.split('"')[3]
|
||||
if '}' in line:
|
||||
break
|
||||
break
|
||||
if os.path.isfile(f"{dir_mod_ark}/appworkshop_346110.acf"):
|
||||
with open(os.path.join(dir_mod_ark, f"appworkshop_346110.acf"), "r") as f:
|
||||
content = f.readlines()
|
||||
content = "".join(content)
|
||||
locale_date = ""
|
||||
for line in content.splitlines():
|
||||
if '\t"WorkshopItemsInstalled"' in line:
|
||||
for line in content.splitlines():
|
||||
if f'\t\t"timeupdated"' in line:
|
||||
locale_date = line.split('"')[3]
|
||||
if '}' in line:
|
||||
break
|
||||
break
|
||||
data = {
|
||||
'itemcount': 1,
|
||||
'publishedfileids[0]': id_mod
|
||||
}
|
||||
zapros = requests.post('http://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1', data=data)
|
||||
json_zapros = zapros.json()
|
||||
steam_date = json_zapros['response']['publishedfiledetails'][0]['time_updated']
|
||||
|
||||
data = {
|
||||
'itemcount': 1,
|
||||
'publishedfileids[0]': id_mod
|
||||
}
|
||||
zapros = requests.post('http://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1', data=data)
|
||||
json_zapros = zapros.json()
|
||||
steam_date = json_zapros['response']['publishedfiledetails'][0]['time_updated']
|
||||
|
||||
if int(steam_date) != int(locale_date):
|
||||
print_line(f"Обновляем мод {id_mod}", flag="CYAN")
|
||||
moddownload(g, m, id_mod, dir_mod_ark)
|
||||
if int(steam_date) != int(locale_date):
|
||||
print_line(f"Обновляем мод {id_mod}", flag="CYAN")
|
||||
moddownload(g, m, id_mod, dir_mod_ark)
|
||||
else:
|
||||
print_line(f"Мод {id_mod} обновлен", flag="GREEN")
|
||||
else:
|
||||
print_line(f"Мод {id_mod} обновлен", flag="GREEN")
|
||||
print_line(f"Информация об обновлении не найдена. Переустанавливаем мод {id_mod}", flag="CYAN")
|
||||
moddownload(g, m, id_mod, dir_mod_ark)
|
||||
|
||||
|
||||
def modupdateall(g, m):
|
||||
@ -858,7 +863,6 @@ def moddownload(g, m, id_mod, dir_mod_ark):
|
||||
f"mv {dir_workshop_ark}/appworkshop_{id_game_workshop}.acf {dir_mod_ark}/appworkshop_{id_game_workshop}.acf")
|
||||
|
||||
|
||||
|
||||
@hlna.command(help='Выключение/включение серверов (без удаления) <hlna switch -m all -d')
|
||||
@click.argument('g', nargs=1)
|
||||
@click.option("-m", required=True, help="Название cервера")
|
||||
@ -1014,7 +1018,6 @@ def start_stop(action, g, m):
|
||||
x = os.system(f"systemctl --user {action} ark_{data['SessionName'].lower()}.service")
|
||||
if x == 0:
|
||||
print_line(f"Готово {action} для {g} {i}", flag="GREEN")
|
||||
|
||||
elif g == "7days":
|
||||
x = os.system(f"systemctl --user {action} 7days.service")
|
||||
if x == 0:
|
||||
|
Loading…
Reference in New Issue
Block a user