Ruff fixes
This commit is contained in:
parent
3e691db708
commit
2f5beca13b
3 changed files with 12 additions and 13 deletions
|
|
@ -3,7 +3,6 @@ Author: Jose Stovall
|
|||
Description: Common utilities used to fetch current server statuses
|
||||
"""
|
||||
|
||||
from typing import List
|
||||
|
||||
from docker import DockerClient
|
||||
from docker.models.containers import Container
|
||||
|
|
@ -11,7 +10,7 @@ from docker.models.containers import Container
|
|||
from server import Server
|
||||
|
||||
|
||||
def list_servers(client: DockerClient, all: bool = False) -> List[dict]:
|
||||
def list_servers(client: DockerClient, all: bool = False) -> list[dict]:
|
||||
"""
|
||||
Distills the container data for all servers on the current host into a usable format
|
||||
Arguments:
|
||||
|
|
@ -20,7 +19,7 @@ def list_servers(client: DockerClient, all: bool = False) -> List[dict]:
|
|||
(List[Dict[str, any]]) A list of results from __extract_info
|
||||
"""
|
||||
|
||||
containers: List[Container] = list(
|
||||
containers: list[Container] = list(
|
||||
filter(
|
||||
lambda x: "itzg/minecraft-server" in x.attrs["Config"]["Image"] and "net.forgeserv.hidden" not in x.labels,
|
||||
client.containers.list(all=all),
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class ServerPingResponse:
|
|||
self.protocol = data["version"]["protocol"]
|
||||
|
||||
def __str__(self):
|
||||
return "Server(description={!r}, icon={!r}, version={!r}, protocol={!r}, players={})".format(self.description, bool(self.icon), self.version, self.protocol, self.players)
|
||||
return f"Server(description={self.description!r}, icon={bool(self.icon)!r}, version={self.version!r}, protocol={self.protocol!r}, players={self.players})"
|
||||
|
||||
|
||||
class Players(list):
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import base64
|
|||
import re
|
||||
from dataclasses import dataclass
|
||||
from os import getenv
|
||||
from typing import Any, List, Union
|
||||
from typing import Any
|
||||
|
||||
from docker.models.containers import Container
|
||||
|
||||
|
|
@ -32,16 +32,16 @@ class ServerConstructorParams:
|
|||
status: str
|
||||
type: str
|
||||
version: str
|
||||
icon: Union[str, None]
|
||||
icon: str | None
|
||||
motd: str
|
||||
name: str
|
||||
online: int
|
||||
max: int
|
||||
players: List[Player]
|
||||
dynmap: Union[str, None]
|
||||
players: list[Player]
|
||||
dynmap: str | None
|
||||
|
||||
|
||||
def ping_container_server(container: Container) -> Union[ServerPingResponse, None]:
|
||||
def ping_container_server(container: Container) -> ServerPingResponse | None:
|
||||
"""Iterates through all Container:Host port binding pairs and attempts to ping the server
|
||||
|
||||
Args:
|
||||
|
|
@ -90,13 +90,13 @@ class Server:
|
|||
self.status: str = params.status
|
||||
self.type: str = params.type
|
||||
self.version: str = params.version
|
||||
self.icon: Union[str, None] = params.icon
|
||||
self.icon: str | None = params.icon
|
||||
self.motd: str = params.motd
|
||||
self.name: str = params.name
|
||||
self.online: int = params.online
|
||||
self.max: int = params.max
|
||||
self.players: List[Player] = params.players
|
||||
self.dynmap: Union[str, None] = params.dynmap
|
||||
self.players: list[Player] = params.players
|
||||
self.dynmap: str | None = params.dynmap
|
||||
|
||||
def asdict(self) -> dict:
|
||||
d = self.__dict__
|
||||
|
|
@ -175,7 +175,7 @@ class Server:
|
|||
# We only care about the right half of the data after the :
|
||||
_, logs = logs.split(" : ")
|
||||
# Find all keys for the log line (universally)
|
||||
keys: List[str] = re.findall("\w+(?=\=)", logs)
|
||||
keys: list[str] = re.findall(r"\w+(?=\=)", logs)
|
||||
ret = LogDerivedInfo()
|
||||
|
||||
for idx, key in enumerate(keys):
|
||||
|
|
|
|||
Loading…
Reference in a new issue