mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Improve the start_server function
This commit is contained in:
parent
d83b964267
commit
e7e337bea1
@ -261,27 +261,18 @@ class Server:
|
|||||||
|
|
||||||
# Checks for eula. Creates one if none detected.
|
# Checks for eula. Creates one if none detected.
|
||||||
# If EULA is detected and not set to true we offer to set it true.
|
# If EULA is detected and not set to true we offer to set it true.
|
||||||
|
e_flag = False
|
||||||
if Helpers.check_file_exists(os.path.join(self.settings["path"], "eula.txt")):
|
if Helpers.check_file_exists(os.path.join(self.settings["path"], "eula.txt")):
|
||||||
f = open(
|
with open(
|
||||||
os.path.join(self.settings["path"], "eula.txt"), "r", encoding="utf-8"
|
os.path.join(self.settings["path"], "eula.txt"), "r", encoding="utf-8"
|
||||||
)
|
) as f:
|
||||||
line = f.readline().lower()
|
line = f.readline().lower()
|
||||||
if line == "eula=true":
|
e_flag = line in [
|
||||||
e_flag = True
|
"eula=true",
|
||||||
|
"eula = true",
|
||||||
elif line == "eula = true":
|
"eula= true",
|
||||||
e_flag = True
|
"eula =true",
|
||||||
|
]
|
||||||
elif line == "eula= true":
|
|
||||||
e_flag = True
|
|
||||||
|
|
||||||
elif line == "eula =true":
|
|
||||||
e_flag = True
|
|
||||||
|
|
||||||
else:
|
|
||||||
e_flag = False
|
|
||||||
else:
|
|
||||||
e_flag = False
|
|
||||||
|
|
||||||
if not e_flag:
|
if not e_flag:
|
||||||
if user_id:
|
if user_id:
|
||||||
@ -293,9 +284,7 @@ class Server:
|
|||||||
"Autostart failed due to EULA being false. "
|
"Autostart failed due to EULA being false. "
|
||||||
"Agree not sent due to auto start."
|
"Agree not sent due to auto start."
|
||||||
)
|
)
|
||||||
return False
|
|
||||||
return False
|
return False
|
||||||
f.close()
|
|
||||||
if Helpers.is_os_windows():
|
if Helpers.is_os_windows():
|
||||||
logger.info("Windows Detected")
|
logger.info("Windows Detected")
|
||||||
else:
|
else:
|
||||||
@ -307,15 +296,16 @@ class Server:
|
|||||||
|
|
||||||
# checks to make sure file is openable (downloaded) and exists.
|
# checks to make sure file is openable (downloaded) and exists.
|
||||||
try:
|
try:
|
||||||
f = open(
|
with open(
|
||||||
os.path.join(
|
os.path.join(
|
||||||
self.server_path,
|
self.server_path,
|
||||||
HelperServers.get_server_data_by_id(self.server_id)["executable"],
|
HelperServers.get_server_data_by_id(self.server_id)["executable"],
|
||||||
),
|
),
|
||||||
"r",
|
"r",
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
)
|
):
|
||||||
f.close()
|
# Can open the file
|
||||||
|
pass
|
||||||
|
|
||||||
except:
|
except:
|
||||||
if user_id:
|
if user_id:
|
||||||
|
Loading…
Reference in New Issue
Block a user