mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-19 09:45:28 +01:00
Fix server importing for bedrock that's not a zip
This commit is contained in:
parent
e1340d61ff
commit
c8c1f301c0
@ -305,8 +305,30 @@ class Stats:
|
|||||||
|
|
||||||
def get_raw_server_stats(self, server_id):
|
def get_raw_server_stats(self, server_id):
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.controller.get_server_obj(server_id)
|
||||||
|
except:
|
||||||
|
return { 'id': server_id,
|
||||||
|
'started': False,
|
||||||
|
'running': False,
|
||||||
|
'cpu': 0,
|
||||||
|
'mem': 0,
|
||||||
|
"mem_percent": 0,
|
||||||
|
'world_name': None,
|
||||||
|
'world_size': None,
|
||||||
|
'server_port': None,
|
||||||
|
'int_ping_results': False,
|
||||||
|
'online': False,
|
||||||
|
'max': False,
|
||||||
|
'players': False,
|
||||||
|
'desc': False,
|
||||||
|
'version': False,
|
||||||
|
'icon': False}
|
||||||
|
|
||||||
server_stats = {}
|
server_stats = {}
|
||||||
server = self.controller.get_server_obj(server_id)
|
server = self.controller.get_server_obj(server_id)
|
||||||
|
if not server:
|
||||||
|
return {}
|
||||||
server_dt = servers_helper.get_server_data_by_id(server_id)
|
server_dt = servers_helper.get_server_data_by_id(server_id)
|
||||||
|
|
||||||
|
|
||||||
@ -314,8 +336,7 @@ class Stats:
|
|||||||
|
|
||||||
# get our server object, settings and data dictionaries
|
# get our server object, settings and data dictionaries
|
||||||
server_obj = self.controller.get_server_obj(server_id)
|
server_obj = self.controller.get_server_obj(server_id)
|
||||||
if server_obj:
|
server_obj.reload_server_settings()
|
||||||
server_obj.reload_server_settings()
|
|
||||||
server_settings = self.controller.get_server_settings(server_id)
|
server_settings = self.controller.get_server_settings(server_id)
|
||||||
server_data = self.controller.get_server_data(server_id)
|
server_data = self.controller.get_server_data(server_id)
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import shutil
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
import tempfile
|
import tempfile
|
||||||
from distutils import dir_util
|
|
||||||
from typing import Union
|
from typing import Union
|
||||||
from peewee import DoesNotExist
|
from peewee import DoesNotExist
|
||||||
|
|
||||||
@ -329,7 +329,10 @@ class Controller:
|
|||||||
helper.ensure_dir_exists(new_server_dir)
|
helper.ensure_dir_exists(new_server_dir)
|
||||||
helper.ensure_dir_exists(backup_path)
|
helper.ensure_dir_exists(backup_path)
|
||||||
server_path = helper.get_os_understandable_path(server_path)
|
server_path = helper.get_os_understandable_path(server_path)
|
||||||
dir_util.copy_tree(server_path, new_server_dir)
|
try:
|
||||||
|
file_helper.copy_dir(server_path, new_server_dir, True)
|
||||||
|
except shutil.Error as ex:
|
||||||
|
logger.error(f"Server import failed with error: {ex}")
|
||||||
|
|
||||||
has_properties = False
|
has_properties = False
|
||||||
for item in os.listdir(new_server_dir):
|
for item in os.listdir(new_server_dir):
|
||||||
@ -418,7 +421,10 @@ class Controller:
|
|||||||
helper.ensure_dir_exists(new_server_dir)
|
helper.ensure_dir_exists(new_server_dir)
|
||||||
helper.ensure_dir_exists(backup_path)
|
helper.ensure_dir_exists(backup_path)
|
||||||
server_path = helper.get_os_understandable_path(server_path)
|
server_path = helper.get_os_understandable_path(server_path)
|
||||||
dir_util.copy_tree(server_path, new_server_dir)
|
try:
|
||||||
|
file_helper.copy_dir(server_path, new_server_dir, True)
|
||||||
|
except shutil.Error as ex:
|
||||||
|
logger.error(f"Server import failed with error: {ex}")
|
||||||
|
|
||||||
has_properties = False
|
has_properties = False
|
||||||
for item in os.listdir(new_server_dir):
|
for item in os.listdir(new_server_dir):
|
||||||
@ -443,7 +449,8 @@ class Controller:
|
|||||||
|
|
||||||
new_id = self.register_server(server_name, server_id, new_server_dir, backup_path, server_command, server_exe,
|
new_id = self.register_server(server_name, server_id, new_server_dir, backup_path, server_command, server_exe,
|
||||||
server_log_file, server_stop, port, server_type='minecraft-bedrock')
|
server_log_file, server_stop, port, server_type='minecraft-bedrock')
|
||||||
os.chmod(full_jar_path, 2775)
|
if os.name != "nt":
|
||||||
|
os.chmod(full_jar_path, 2775)
|
||||||
return new_id
|
return new_id
|
||||||
|
|
||||||
def import_bedrock_zip_server(self, server_name: str, zip_path: str, server_exe: str, port: int):
|
def import_bedrock_zip_server(self, server_name: str, zip_path: str, server_exe: str, port: int):
|
||||||
@ -491,7 +498,9 @@ class Controller:
|
|||||||
|
|
||||||
new_id = self.register_server(server_name, server_id, new_server_dir, backup_path, server_command, server_exe,
|
new_id = self.register_server(server_name, server_id, new_server_dir, backup_path, server_command, server_exe,
|
||||||
server_log_file, server_stop, port, server_type='minecraft-bedrock')
|
server_log_file, server_stop, port, server_type='minecraft-bedrock')
|
||||||
os.chmod(full_jar_path, 2775)
|
if os.name != "nt":
|
||||||
|
os.chmod(full_jar_path, 2775)
|
||||||
|
|
||||||
return new_id
|
return new_id
|
||||||
|
|
||||||
#************************************************************************************************
|
#************************************************************************************************
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
<i class="fas fa-cogs"></i>{{ translate('serverDetails', 'config', data['lang']) }}</a>
|
<i class="fas fa-cogs"></i>{{ translate('serverDetails', 'config', data['lang']) }}</a>
|
||||||
</li>
|
</li>
|
||||||
{% end %}
|
{% end %}
|
||||||
{% if data['permissions']['Players'] in data['user_permissions'] %}
|
{% if data['permissions']['Players'] in data['user_permissions'] and data['server_data']['type'] != 'minecraft-bedrock' %}
|
||||||
<li class="nav-item term-nav-item">
|
<li class="nav-item term-nav-item">
|
||||||
<a class="nav-link {% if data['active_link'] == 'admin_controls' %}active{% end %}" href="/panel/server_detail?id={{ data['server_stats']['server_id']['server_id'] }}&subpage=admin_controls" role="tab" aria-selected="true">
|
<a class="nav-link {% if data['active_link'] == 'admin_controls' %}active{% end %}" href="/panel/server_detail?id={{ data['server_stats']['server_id']['server_id'] }}&subpage=admin_controls" role="tab" aria-selected="true">
|
||||||
<i class="fas fa-users"></i>{{ translate('serverDetails', 'playerControls', data['lang']) }}</a>
|
<i class="fas fa-users"></i>{{ translate('serverDetails', 'playerControls', data['lang']) }}</a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user