Small tweaks

This commit is contained in:
oitsjustjose 2025-06-18 21:53:19 -05:00
commit d6437c5397
6 changed files with 21 additions and 14 deletions

1
.gitignore vendored
View file

@ -18,3 +18,4 @@ tidbyt-desktop-companion.onefile-build
tmp.star tmp.star
tmp.webp tmp.webp
weapons weapons
.envrc

11
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,11 @@
{
"configurations": [
{
"name": "Python Debugger: FastAPI",
"type": "debugpy",
"request": "launch",
"module": "fastapi",
"args": ["run", "src/server/main.py"]
}
]
}

0
pixlet.aarch64 Normal file → Executable file
View file

0
pixlet.x86_64 Normal file → Executable file
View file

View file

@ -17,6 +17,7 @@ class PixletHelper:
self.root_path: Path = Path("./").resolve() self.root_path: Path = Path("./").resolve()
self.pixlet: Path = self.root_path.joinpath(f"pixlet.{machine()}").resolve() self.pixlet: Path = self.root_path.joinpath(f"pixlet.{machine()}").resolve()
self.device_id: str = getenv("TIDBYT_DEVICE_ID", "") self.device_id: str = getenv("TIDBYT_DEVICE_ID", "")
self.api_token: str = getenv("TIDBYT_API_TOKEN", "")
def push_to_tidbyt(self, renderable: Renderable) -> bool: def push_to_tidbyt(self, renderable: Renderable) -> bool:
"""Pushes a renderable to the Tidbyt device """Pushes a renderable to the Tidbyt device
@ -40,9 +41,7 @@ class PixletHelper:
""" """
output_path = self.__prepare_file(renderable) output_path = self.__prepare_file(renderable)
with Popen( with Popen([self.pixlet, "render", str(output_path)], stdout=PIPE, stderr=PIPE) as proc:
[self.pixlet, "render", str(output_path)], stdout=PIPE, stderr=PIPE
) as proc:
exit_code = proc.wait() exit_code = proc.wait()
stdout, stderr = self.__get_decoded_out(proc) stdout, stderr = self.__get_decoded_out(proc)
if exit_code != 0 and (stdout or stderr): if exit_code != 0 and (stdout or stderr):
@ -64,6 +63,8 @@ class PixletHelper:
[ [
self.pixlet, self.pixlet,
"push", "push",
"--api-token",
self.api_token,
"--installation-id", "--installation-id",
"automation", "automation",
self.device_id, self.device_id,
@ -81,9 +82,7 @@ class PixletHelper:
else: else:
stdout, stderr = self.__get_decoded_out(proc) stdout, stderr = self.__get_decoded_out(proc)
if exit_code != 0 and (stdout or stderr): if exit_code != 0 and (stdout or stderr):
self.logger.warning( self.logger.warning(f"__display call failed after 5 attempts: {stdout or stderr}")
f"__display call failed after 5 attempts: {stdout or stderr}"
)
return False return False
def __prepare_file(self, renderable: Renderable) -> Path: def __prepare_file(self, renderable: Renderable) -> Path:
@ -106,11 +105,9 @@ class PixletHelper:
if renderable.is_dynamic: if renderable.is_dynamic:
args = renderable.resolve_template_keys() args = renderable.resolve_template_keys()
for key in renderable.template_keys: for key in renderable.template_keys:
if not key in args: if key not in args:
raise Exception( raise Exception(f"Failed to render Pixlet Configuration for {str(renderable.file_path)} -- missing key '{key}'")
f"Failed to render Pixlet Configuration for {renderable.for_state.name} -- missing key '{key}'" data = data.replace(key, str(args[key]))
)
data = data.replace(key, args[key])
with open(output_path, "w", encoding="utf8") as handle: with open(output_path, "w", encoding="utf8") as handle:
handle.write(data) handle.write(data)

View file

@ -22,7 +22,6 @@ class Server:
max_players: int max_players: int
online_players: int online_players: int
server_dynmap_url: Union[None, str]
server_health: str server_health: str
server_icon: str server_icon: str
server_motd: str server_motd: str
@ -63,7 +62,6 @@ class ForgeServ(Renderable):
Server( Server(
max_players=serv["max"], max_players=serv["max"],
online_players=serv["online"], online_players=serv["online"],
server_dynmap_url=serv["dynmap"],
server_health=serv["health"], server_health=serv["health"],
server_icon=serv["icon"], server_icon=serv["icon"],
server_motd=serv["motd"], server_motd=serv["motd"],