Cleanup print statements, comments
This commit is contained in:
parent
594a1160a2
commit
c58b095248
1 changed files with 10 additions and 7 deletions
|
|
@ -63,17 +63,21 @@ class Server:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __ping_server(attrs: dict) -> Union[ServerPingResponse, None]:
|
def __ping_server(attrs: dict) -> Union[ServerPingResponse, None]:
|
||||||
# Try to ping server if it's running to get users online
|
"""Iterates through all Container:Host port binding pairs and attempts to ping the server
|
||||||
|
|
||||||
|
Args:
|
||||||
|
attrs (dict): The container's attributes
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Union[ServerPingResponse, None]: The info derived from the Ping, if available, otherwise None (failure case)
|
||||||
|
"""
|
||||||
|
|
||||||
for key in attrs["HostConfig"]["PortBindings"]:
|
for key in attrs["HostConfig"]["PortBindings"]:
|
||||||
# We have to do this nested for loop to get each Container->Host binding to get the actual port of the server
|
# We have to do this nested for loop to get each Container->Host binding to get the actual port of the server
|
||||||
# By default they'd otherwise all show up as 25565.. :/
|
# By default they'd otherwise all show up as 25565.. :/
|
||||||
for binding in attrs["HostConfig"]["PortBindings"][key]:
|
for binding in attrs["HostConfig"]["PortBindings"][key]:
|
||||||
try:
|
try:
|
||||||
server_port = int(binding["HostPort"])
|
ping_resp = ping_server("localhost", port=int(binding["HostPort"]))
|
||||||
print(f"Pinging localhost:{server_port}")
|
|
||||||
|
|
||||||
ping_resp = ping_server("localhost", port=server_port)
|
|
||||||
print(f"Pinged: {ping_resp}")
|
|
||||||
return ping_resp
|
return ping_resp
|
||||||
except ValueError:
|
except ValueError:
|
||||||
continue
|
continue
|
||||||
|
|
@ -85,7 +89,6 @@ class Server:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
log_info = Server.parse_log_for_info(attrs["State"]["Health"]["Log"][-1]["Output"])
|
log_info = Server.parse_log_for_info(attrs["State"]["Health"]["Log"][-1]["Output"])
|
||||||
print(f"Log Info is done! \n\tlog_info.max={log_info.max}\n\tlog_info.motd={log_info.motd}\n\tlog_info.version={log_info.version}")
|
|
||||||
players = [Player(name=pl.name, uuid=pl.id) for pl in ping_resp.players]
|
players = [Player(name=pl.name, uuid=pl.id) for pl in ping_resp.players]
|
||||||
|
|
||||||
return ServerConstructorParams(
|
return ServerConstructorParams(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue