начал разделять функцию config_ark

This commit is contained in:
Евгений Храмов 2023-05-16 17:43:00 +03:00
parent c8632510f2
commit 0754de1c0d

100
hlna.py

@ -199,15 +199,7 @@ def ports(port, ports_arr, flag):
return port
def config_ark(list_config=list_config):
"""конфигурирование сервера арк"""
create_dir(dir_server_ark)
create_dir(dir_maps_ark)
"""Сбор данных для конфига"""
cluster_id = ""
cluster_dir_override = ""
def clustering():
count_cluster = check_int("""Укажите требуется ли кластер? default: Нет
1. Да
2. Нет
@ -222,19 +214,18 @@ def config_ark(list_config=list_config):
create_dir(dir_server_ark + cluster_id)
cluster_dir_override = (dir_server_ark + cluster_id)
break
else:
cluster_server = False
else:
cluster_server = False
if list_config:
print("Уже установленные карты: ")
for i in list_config:
data = read_yaml(i, game="ARK")
print(f"{i} : {data['map']}")
def num_maps():
count_maps = check_int("Укажите количество карт: \n")
if count_maps == 0: # 0 возвращает check_int когда, ничего не было введено
count_maps = 1
return count_maps
def name_maps(count_maps=""):
for i in range(count_maps):
while True:
"""Проверка на выбор карты из списка"""
@ -257,11 +248,6 @@ def config_ark(list_config=list_config):
if 0 < amount_map <= 12:
break
if list_config:
port_s, query_p, rcon_p = ports_array()
else:
port_s = query_p = rcon_p = []
if amount_map == 1:
map_s = "TheIsland"
elif amount_map == 2:
@ -289,30 +275,58 @@ def config_ark(list_config=list_config):
else:
# Если вдруг каким-то боком проверка не отработает и не будет нужной цифры
map_s = 'TheIsland'
return map_s
def name_servers(list_config=list_config, map_s=""):
if list_config:
data = read_yaml(list_config[-1], game="ARK")
while True:
name_server = input("Укажите название Сервера: \n")
if name_server == "":
if map_s in list_config:
count = 1
new_name = map_s
while new_name in list_config:
new_name = f"{map_s}{str(count)}"
count += 1
list_config.append(new_name)
print(list_config)
break
else:
list_config.append(map_s)
break
else:
if name_server in list_config:
print_line("Имя занято")
else:
list_config.append(name_server) # если enter, то ставим последним элементом карту
break
def config_ark(list_config=list_config):
"""конфигурирование сервера арк"""
create_dir(dir_server_ark)
create_dir(dir_maps_ark)
cluster_id = ""
cluster_dir_override = ""
cluster_server = clustering()
if list_config:
print_line("Уже установленные карты: ")
for i in list_config:
data = read_yaml(i, game="ARK")
print_line(f"{i} : {data['map']}")
num_maps()
map_s = name_maps()
name_servers()
if list_config:
data = read_yaml(list_config[-1], game="ARK")
while True:
name_server = input("Укажите название Сервера: \n")
if name_server == "":
if map_s in list_config:
count = 1
new_name = map_s
while new_name in list_config:
new_name = f"{map_s}{str(count)}"
count += 1
list_config.append(new_name)
print(list_config)
break
else:
list_config.append(map_s)
break
else:
if name_server in list_config:
print_line("Имя занято")
else:
list_config.append(name_server) # если enter, то ставим последним элементом карту
break
port_s, query_p, rcon_p = ports_array()
else:
port_s = query_p = rcon_p = []
port = check_int("Укажите порт сервера: ")
port_server = ports(port, port_s, True)