Revert to original popen scheme

This commit is contained in:
Andrew 2022-02-26 11:51:28 -05:00
parent b6b8a1c14a
commit 92f9bceaf9

View File

@ -201,8 +201,8 @@ class Server:
logger.info(f"Launching Server {self.name} with command {self.server_command}")
console.info(f"Launching Server {self.name} with command {self.server_command}")
#Checks for eula. Creates one if none detected.
#If EULA is detected and not set to one of these true vaiants we offer to set it true.
#Checks for eula. Creates one if none detected.
#If EULA is detected and not set to one of these true vaiants we offer to set it true.
if helper.check_file_exists(os.path.join(self.settings['path'], 'eula.txt')):
f = open(os.path.join(self.settings['path'], 'eula.txt'), 'r', encoding='utf-8')
line = f.readline().lower()
@ -240,48 +240,24 @@ class Server:
logger.info(f"Starting server in {self.server_path} with command: {self.server_command}")
if not helper.is_os_windows() and servers_helper.get_server_type_by_id(self.server_id) == "minecraft-bedrock":
print("in catch")
my_env = os.environ
my_env["PATH"] = 'LD_LIBRARY_PATH='+self.server_path
try:
self.process = subprocess.Popen(
self.server_command, cwd=self.server_path, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=my_env)
except Exception as ex:
#Checks for java on initial fail
if os.system("java -version") == 32512:
if user_id:
websocket_helper.broadcast_user(user_id, 'send_start_error',{
'error': translation.translate('error', 'noJava', user_lang).format(self.name)
})
return False
else:
logger.error(f"Server {self.name} failed to start with error code: {ex}")
try:
self.process = subprocess.Popen(
self.server_command, cwd=self.server_path, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
except Exception as ex:
#Checks for java on initial fail
if os.system("java -version") == 32512:
if user_id:
websocket_helper.broadcast_user(user_id, 'send_start_error',{
'error': translation.translate('error', 'start-error', user_lang).format(self.name, ex)
})
return False
else:
try:
self.process = subprocess.Popen(
self.server_command, cwd=self.server_path, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
except Exception as ex:
#Checks for java on initial fail
if os.system("java -version") == 32512:
if user_id:
websocket_helper.broadcast_user(user_id, 'send_start_error',{
'error': translation.translate('error', 'noJava', user_lang).format(self.name)
})
return False
else:
logger.error(f"Server {self.name} failed to start with error code: {ex}")
if user_id:
websocket_helper.broadcast_user(user_id, 'send_start_error',{
'error': translation.translate('error', 'start-error', user_lang).format(self.name, ex)
})
'error': translation.translate('error', 'noJava', user_lang).format(self.name)
})
return False
else:
logger.error(f"Server {self.name} failed to start with error code: {ex}")
if user_id:
websocket_helper.broadcast_user(user_id, 'send_start_error',{
'error': translation.translate('error', 'start-error', user_lang).format(self.name, ex)
})
return False
out_buf = ServerOutBuf(self.process, self.server_id)