mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fix pylint no-self-use
This commit is contained in:
parent
b69cdd757e
commit
9f30ca3931
@ -7,9 +7,7 @@ import base64
|
||||
import typing as t
|
||||
|
||||
from app.classes.shared.null_writer import NullWriter
|
||||
from app.classes.minecraft.mc_ping import ping
|
||||
from app.classes.models.management import HostStats
|
||||
from app.classes.models.servers import HelperServers
|
||||
from app.classes.shared.helpers import Helpers
|
||||
|
||||
with redirect_stderr(NullWriter()):
|
||||
@ -218,32 +216,6 @@ class Stats:
|
||||
|
||||
return level_total_size
|
||||
|
||||
def get_server_players(self, server_id):
|
||||
|
||||
server = HelperServers.get_server_data_by_id(server_id)
|
||||
|
||||
logger.info(f"Getting players for server {server}")
|
||||
|
||||
# get our settings and data dictionaries
|
||||
# server_settings = server.get('server_settings', {})
|
||||
# server_data = server.get('server_data_obj', {})
|
||||
|
||||
# TODO: search server properties file for possible override of 127.0.0.1
|
||||
internal_ip = server["server_ip"]
|
||||
server_port = server["server_port"]
|
||||
|
||||
logger.debug(f"Pinging {internal_ip} on port {server_port}")
|
||||
if HelperServers.get_server_type_by_id(server_id) != "minecraft-bedrock":
|
||||
int_mc_ping = ping(internal_ip, int(server_port))
|
||||
|
||||
ping_data = {}
|
||||
|
||||
# if we got a good ping return, let's parse it
|
||||
if int_mc_ping:
|
||||
ping_data = Stats.parse_server_ping(int_mc_ping)
|
||||
return ping_data["players"]
|
||||
return []
|
||||
|
||||
@staticmethod
|
||||
def parse_server_ping(ping_obj: object):
|
||||
online_stats = {}
|
||||
|
@ -192,9 +192,9 @@ class PanelHandler(BaseHandler):
|
||||
total_players = 0
|
||||
for server in page_data["servers"]:
|
||||
total_players += len(
|
||||
self.controller.servers.stats.get_server_players(
|
||||
self.controller.servers.get_server_instance_by_id(
|
||||
server["server_data"]["server_id"]
|
||||
)
|
||||
).get_server_players()
|
||||
)
|
||||
page_data["num_players"] = total_players
|
||||
|
||||
@ -541,7 +541,9 @@ class PanelHandler(BaseHandler):
|
||||
page_data["waiting_start"] = False
|
||||
page_data[
|
||||
"get_players"
|
||||
] = lambda: self.controller.servers.stats.get_server_players(server_id)
|
||||
] = lambda: self.controller.servers.get_server_instance_by_id(
|
||||
server_id
|
||||
).get_server_players()
|
||||
page_data["active_link"] = subpage
|
||||
page_data["permissions"] = {
|
||||
"Commands": EnumPermissionsServer.COMMANDS,
|
||||
@ -879,7 +881,9 @@ class PanelHandler(BaseHandler):
|
||||
)
|
||||
page_data[
|
||||
"get_players"
|
||||
] = lambda: self.controller.servers.stats.get_server_players(server_id)
|
||||
] = lambda: self.controller.servers.get_server_instance_by_id(
|
||||
server_id
|
||||
).get_server_players()
|
||||
page_data["active_link"] = "schedules"
|
||||
page_data["permissions"] = {
|
||||
"Commands": EnumPermissionsServer.COMMANDS,
|
||||
@ -947,7 +951,9 @@ class PanelHandler(BaseHandler):
|
||||
schedule = self.controller.management.get_scheduled_task_model(sch_id)
|
||||
page_data[
|
||||
"get_players"
|
||||
] = lambda: self.controller.servers.stats.get_server_players(server_id)
|
||||
] = lambda: self.controller.servers.get_server_instance_by_id(
|
||||
server_id
|
||||
).get_server_players()
|
||||
page_data["active_link"] = "schedules"
|
||||
page_data["permissions"] = {
|
||||
"Commands": EnumPermissionsServer.COMMANDS,
|
||||
|
Loading…
Reference in New Issue
Block a user