unit_tests
This commit is contained in:
29
hlna.py
29
hlna.py
@@ -69,42 +69,29 @@ def hlna():
|
||||
@click.argument('g', nargs=1)
|
||||
@click.option('-d',required=True , help="Путь до zip архива")
|
||||
def restore(g, d):
|
||||
directory_to_extract_to = "*******"
|
||||
"Получение пути к файлам внутри архива, может понадобиться при раскидывании по местам"
|
||||
"==================================================================================="
|
||||
"Получение пути к файлам внутри архива"
|
||||
with zipfile.ZipFile(d, 'r') as zip_file:
|
||||
files = zip_file.namelist()
|
||||
"===================================================================================="
|
||||
|
||||
"Извлечение файлов"
|
||||
"======================="
|
||||
for i in files:
|
||||
with zipfile.ZipFile(d, 'r') as zip_file:
|
||||
s = i.split("/")
|
||||
s.pop(-1)
|
||||
s = "/"+'/'.join(s)+'/' # вот тут где-то еще надо начало пути проверить и если home_dir другой заменить
|
||||
print(i,colorama.Fore.GREEN + "- перемещен" + colorama.Style.RESET_ALL )
|
||||
zip_file.extract(i, '/')
|
||||
"======================="
|
||||
"Извлечение из архива всего, скорее всего не пригодится"
|
||||
#with zipfile.ZipFile(d, 'r') as zip_file:
|
||||
# zip_file.extractall(directory_to_extract_to)
|
||||
"--------------------------"
|
||||
|
||||
path_extarct = "./" if g == 'test' else "/"
|
||||
zip_file.extract(i, path_extarct)
|
||||
print(i, colorama.Fore.GREEN + "- перемещен" + colorama.Style.RESET_ALL)
|
||||
print_line(f"Бэкап {d} восстановлен", flag="GREEN")
|
||||
|
||||
|
||||
@hlna.command(help='Бэкап серверов выбранной игры <hlna backup ark')
|
||||
@click.argument('g', nargs=1)
|
||||
def backup(g):
|
||||
if g == "ark":
|
||||
if g == "ark" or g == "ark_test":
|
||||
source = [f"{dir_config}"]
|
||||
backup_path = input("Введите конечный путь для бэкапа, по умолчанию ******")
|
||||
#backup_path = input("Введите конечный путь для бэкапа, по умолчанию ******")
|
||||
backup_path = f"{dir_server_ark}Backups" if g=="ark" else f"{dir_server_ark}Backups/test_backup"
|
||||
if not backup_path:
|
||||
backup_path = f"{dir_server_ark}Backups"
|
||||
|
||||
today = backup_path + os.sep + time.strftime('%Y_%m_%d')
|
||||
target = f"{backup_path}/" + g + "_backup-" + time.strftime('%H_%M_%S') + '.zip'
|
||||
target = f"{backup_path}/" + g + "_backup-" + time.strftime('%Y_%m_%d') + '.zip'
|
||||
create_dir(backup_path)
|
||||
with zipfile.ZipFile(target, 'w', zipfile.ZIP_DEFLATED, True) as myzip:
|
||||
for source_folder in source:
|
||||
|
||||
Reference in New Issue
Block a user