Исправление ошибок и добавлена функция просмотра конфига сервера
This commit is contained in:
parent
a8308a3bb2
commit
3e8497db2d
0
111.py
Normal file
0
111.py
Normal file
60
dodo.py
60
dodo.py
@ -18,14 +18,16 @@ def dodo():
|
||||
pass
|
||||
|
||||
list_config = next(os.walk(config_dodo), (None, None, []))[2] # [] if no file
|
||||
list_config.remove('.directory')
|
||||
x = list_config.count('.directory')
|
||||
if x>0:
|
||||
list_config.remove('.directory')
|
||||
|
||||
|
||||
def print_line(text):
|
||||
"Добавление тире вокруг текста, потом сюда можно поместить и расскраску текста"
|
||||
print(Fore.YELLOW + "-"*25)
|
||||
print(Fore.GREEN + text)
|
||||
print(Fore.YELLOW + "-"*25 + Fore.RESET_ALL)
|
||||
print(colorama.Fore.YELLOW + "-"*25)
|
||||
print(colorama.Fore.GREEN + text)
|
||||
print(colorama.Fore.YELLOW + "-"*25 + colorama.Style.RESET_ALL)
|
||||
|
||||
|
||||
def create_dir(directory):
|
||||
@ -40,7 +42,7 @@ def check_int(number=""):
|
||||
try:
|
||||
x = input(number)
|
||||
if x == "":
|
||||
return x
|
||||
return 0
|
||||
x = x.replace(' ', '')
|
||||
x = x.replace(',', '')
|
||||
x = int(x)
|
||||
@ -72,7 +74,7 @@ def config(map_server=list_config):
|
||||
1. Да
|
||||
2. Нет
|
||||
: """)
|
||||
if count_cluster == "":
|
||||
if count_cluster == 0:
|
||||
count_cluster = 2
|
||||
if count_cluster == 1:
|
||||
cluster_server = True
|
||||
@ -90,7 +92,7 @@ def config(map_server=list_config):
|
||||
print(i)
|
||||
|
||||
count_maps = check_int("Укажите количество карт: \n")
|
||||
if count_maps == "":
|
||||
if count_maps == 0:
|
||||
count_maps = 1
|
||||
for i in range(count_maps):
|
||||
while True:
|
||||
@ -110,10 +112,10 @@ def config(map_server=list_config):
|
||||
11. Lost Island
|
||||
12. Fjordur
|
||||
: """)
|
||||
if amount_map == 0:
|
||||
amount_map = i + 1
|
||||
if 0<amount_map<=12:
|
||||
break
|
||||
if amount_map == "":
|
||||
amount_map=i+1
|
||||
match amount_map:
|
||||
case 1:
|
||||
map_server.append("TheIsland")
|
||||
@ -145,7 +147,7 @@ def config(map_server=list_config):
|
||||
name_server = map_server[-1]
|
||||
while True:
|
||||
port_server = check_int("Укажите порт Сервера <7777>: \n")
|
||||
if port_server == "":
|
||||
if port_server == 0:
|
||||
if port_s == []:
|
||||
port_server = 7777
|
||||
else:
|
||||
@ -157,7 +159,7 @@ def config(map_server=list_config):
|
||||
break
|
||||
while True:
|
||||
query_port = check_int("Укажите Query-порт Сервера <27015>: \n")
|
||||
if query_port == "":
|
||||
if query_port == 0:
|
||||
if query_p == []:
|
||||
query_port = 27015
|
||||
else:
|
||||
@ -196,7 +198,26 @@ def yaml_create(cluster_server, map_server, name_server, port_server, query_port
|
||||
settings_dodo[0]['clusterdir'] = cluster_dir_override
|
||||
with open(config_dodo + f"{map_server[-1]}", 'w') as yamlfile:
|
||||
data = yaml.dump(settings_dodo, yamlfile)
|
||||
print(Fore.GREEN + "Конфиг создан" + Fore.RESET_ALL)
|
||||
print(colorama.Fore.GREEN + "Конфиг создан" + colorama.Style.RESET_ALL)
|
||||
@dodo.command()
|
||||
def servers(map_servers=list_config):
|
||||
if map_servers==[]:
|
||||
print("Сервера не установлены")
|
||||
else:
|
||||
for i in map_servers:
|
||||
cluster_server, name_server, port_server, query_port, password_server, max_players, dir_server, mods_id, listen_server, cluster_id, cluster_dir_ovverride = read_yaml(i)
|
||||
print(f"""
|
||||
Сервер: {i}
|
||||
Имя сервера: {name_server}
|
||||
Кластер: {cluster_server}
|
||||
Порт сервера: {port_server}
|
||||
Query порт: {query_port}
|
||||
Пароль: {password_server}
|
||||
Максимальное кол-во игроков: {max_players}
|
||||
Моды: {mods_id}
|
||||
Кластер id: {cluster_id}""")
|
||||
print("\n")
|
||||
|
||||
|
||||
@dodo.command()
|
||||
def start(map_server=list_config):
|
||||
@ -204,17 +225,14 @@ def start(map_server=list_config):
|
||||
while True:
|
||||
"Проверка на выбор имеющихся карт"
|
||||
for i in range(len(map_server)):
|
||||
print(f"{i}) {map_server[i]}")
|
||||
map_list = check_int(map_server)
|
||||
for k in range(map_list):
|
||||
if 0>map_list[k]>len(map_list) and len(map_list)>len(map_server):
|
||||
print("Укажите карты для установки в формате 1,3,5 или 145 или 1 2 3")
|
||||
else:
|
||||
print(f"{i+1}) {map_server[i]}")
|
||||
map_list = check_int("\n")
|
||||
#for k in range(map_list):
|
||||
# if 0>int(map_list[k])>map_list and len(str(map_list))>len(str(map_server)):
|
||||
# print("Укажите карты для установки в формате 1,3,5 или 145 или 1 2 3")
|
||||
# else:
|
||||
break
|
||||
|
||||
|
||||
|
||||
|
||||
for j in str(map_list):
|
||||
map_choise.append(map_server[int(j) - 1])
|
||||
map_server = map_choise
|
||||
|
Loading…
Reference in New Issue
Block a user