добавлен label но не на 100%

This commit is contained in:
sitisll 2023-02-22 19:22:16 +03:00
parent 7ae27b8e81
commit 70fc3e9930

57
hlna.py

@ -25,24 +25,20 @@ listen_server = True
def hlna():
pass
list_config = next(os.walk(config_hlna), (None, None, []))[2] # [] if no file
x = list_config.count('.directory')
y = list_config.count('logs')
if x>0:
list_config.remove('.directory')
if y>0:
list_config.remove('logs')
def find_file(path):
"Находим все конфиги в зависимости от пути"
arr = next(os.walk(path), (None, None, []))[2] # [] if no file
x = list_config.count('.directory')
y = list_config.count('logs')
if x>0:
arr.remove('.directory')
if y>0:
arr.remove('logs')
delist_config = next(os.walk(config_hlna+"deactivated"), (None, None, []))[2] # [] if no file
x = list_config.count('.directory')
y = list_config.count('logs')
if x>0:
list_config.remove('.directory')
if y>0:
list_config.remove('logs')
list_config = find_file(config_hlna)
delist_config = find_file(config_hlna+"deactivated")
def print_line(text):
@ -71,6 +67,8 @@ def check_int(number=""):
return x
except ValueError:
print("Введите число")
create_dir(dir_server)
create_dir(config_hlna)
@ -89,6 +87,7 @@ def config(name_server=list_config):
: """)
if count_cluster == 0: # 0 возвращает функция chek_int, если ничего не было введено
count_cluster = 2
if count_cluster == 1:
cluster_server = True
cluster_id = input("Укажите id для кластера, любое сочетание символов: \n")
@ -96,11 +95,13 @@ def config(name_server=list_config):
cluster_dir_override = (dir_server + cluster_id)
else:
cluster_server = False
if name_server != []:
print("Уже установленные карты: ")
for i in name_server:
con = read_yaml(i)
print(f"{i} : {con['map']}")
count_maps = check_int("Укажите количество карт: \n")
if count_maps == 0: # 0 возрвращает check_int когда, ничего не было введено
count_maps = 1
@ -109,12 +110,6 @@ def config(name_server=list_config):
while True:
"Проверка на выбор карты из списка"
for k in name_server:
data = read_yaml(k)
port_s.append(data['Port'])
query_p.append(data['QueryPort'])
os.system("clear")
amount_map = check_int("""Выберите карту из списка указав номер
1. The Island
@ -135,6 +130,12 @@ def config(name_server=list_config):
if 0<amount_map<=12:
break
for k in name_server:
data = read_yaml(k)
port_s.append(data['Port'])
query_p.append(data['QueryPort'])
if amount_map == 1:
map_s = "TheIsland"
elif amount_map == 2:
@ -150,7 +151,7 @@ def config(name_server=list_config):
elif amount_map == 7:
map_s = "Valguero_P"
elif amount_map == 8:
map_S = "Genesis"
map_s = "Genesis"
elif amount_map == 9:
map_s = "CrystalIsles"
elif amount_map == 10:
@ -159,11 +160,16 @@ def config(name_server=list_config):
map_s = "LostIsland"
elif amount_map == 12:
map_s = "Fjordur"
name_server.append(input("Укажите название Сервера: \n"))
if name_server[-1] == "":
name_server.pop()
name_server.append(map_s)
label = input("Укажите метку для запуска или конфигурирования этой карты, по умолчанию название карты")
if label == "":
label = map_s
while True:
port_server = check_int("Укажите порт Сервера <7777>: \n")
if port_server == 0:
@ -193,13 +199,14 @@ def config(name_server=list_config):
if max_players == 0:
max_players = 70
yaml_create(cluster_server, map_s, name_server[-1], port_server, query_port, password_server, max_players, cluster_id, cluster_dir_override)
yaml_create(cluster_server, map_s, name_server[-1], port_server, query_port, password_server, max_players, cluster_id, cluster_dir_override, label)
def yaml_create(cluster_server, map_s, name_server, port_server, query_port, password_server, max_players, cluster_id, cluster_dir_override):
def yaml_create(cluster_server, map_s, name_server, port_server, query_port, password_server, max_players, cluster_id, cluster_dir_override, label):
settings_hlna = [
{
'map' : map_s,
'label' : label,
'Cluster' : cluster_server,
'SessionName' : name_server,
'Port' : port_server,