This commit is contained in:
sitisll 2023-06-01 13:37:16 +03:00
parent 785edb0f49
commit 1bc39cc5e7
7 changed files with 34 additions and 7 deletions

BIN
ark_backup13_17_31.zip Normal file

Binary file not shown.

BIN
ark_backup13_17_46.zip Normal file

Binary file not shown.

BIN
ark_backup13_25_07.zip Normal file

Binary file not shown.

BIN
ark_backup13_27_48.zip Normal file

Binary file not shown.

BIN
ark_backup13_28_59.zip Normal file

Binary file not shown.

BIN
ark_backup13_29_35.zip Normal file

Binary file not shown.

41
hlna.py

@ -3,6 +3,7 @@ import os
import re
import sys
import zlib
import time
import struct
import logging
import datetime
@ -11,13 +12,14 @@ import subprocess
import yaml
import click
import zipfile
import colorama
import hlnaui
from pathlib import Path
from rcon.source import Client
from PyQt6 import QtWidgets
from rcon.source import Client
import hlnaui
home_dir = Path.home()
@ -63,6 +65,32 @@ def hlna():
pass
@hlna.command(help='Бэкап серверов выбранной игры <hlna backup ark -m all -i 111111111>')
@click.argument('g', nargs=1)
def backup(g):
if g == "ark":
source = [f"{dir_config}"]
backup_path = input("Введите конечный путь для бэкапа, по умолчанию ******")
if not backup_path:
backup_path = "/home/a11"
today= backup_path + os.sep + time.strftime('%Y_%m_%d')
target = f"{backup_path}/" + g + "_backup-"+ time.strftime('%H_%M_%S') + '.zip'
create_dir(backup_path)
with zipfile.ZipFile(target, 'w', zipfile.ZIP_DEFLATED, True) as myzip:
for source_folder in source:
for root,dirs,files in os.walk(source_folder):
for file in files:
path = os.path.join(root, file)
myzip.write(path)
print(path, colorama.Fore.GREEN + "- перемещен" + colorama.Style.RESET_ALL )
print(colorama.Fore.GREEN + f"Конфиги сохранены в {target}" + colorama.Style.RESET_ALL )
elif g == "7days":
pass
else:
print("Поддерживает только ark и 7days")
def unpack(src, dst):
"""Добавить документацию"""
with open(src, 'rb') as f:
@ -140,7 +168,7 @@ def get_external_ip():
return response.text
def print_line(*text, flag=""):
def print_line(*text, flag="", sep=" ", end="\n"):
"""Добавление обводки вокруг текста, покраска"""
if flag == "RED":
color = colorama.Fore.RED
@ -154,7 +182,7 @@ def print_line(*text, flag=""):
color = colorama.Fore.WHITE
len_text = len(text)
print(colorama.Fore.LIGHTGREEN_EX + "." * len_text)
print(color, *text)
print(color, *text, sep=sep, end=end)
print(colorama.Fore.LIGHTGREEN_EX + "." * len_text + colorama.Style.RESET_ALL)
@ -778,7 +806,7 @@ def status(list_config=list_config):
@click.option('-m', default='all', help="Название карты для запуска или all для запуска все карт")
def start(g, m):
"""Запускает сервер выбранной игры"""
# добавить проверку на ввод аргумента ark/7day если else: давать подсказку
# добавить проверку на ввод аргумента ark/7days если else: давать подсказку
# если нет конфигов, то выводим что серверов нет
g = g.lower()
if g == "ark":
@ -936,7 +964,6 @@ def zero(x=""):
"""Потом пригодится (нет)"""
return ""
if not os.path.exists(dir_config + "config"):
dir_server = path_server()
else: