From 21c1a68ec1795e38038db5992e7d6944c844e5f2 Mon Sep 17 00:00:00 2001 From: xpamych Date: Wed, 7 Jun 2023 17:49:16 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D0=BF=D1=8B=D1=82=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B2=20=D0=B7=D0=BC=D0=B5=D0=B9=D0=BA=D1=83)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hlna.py | 91 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 47 insertions(+), 44 deletions(-) diff --git a/hlna.py b/hlna.py index 95011c3..3f01062 100755 --- a/hlna.py +++ b/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='Выключение/включение серверов (без удаления)