From 1a2017975d1593fed22fb909d47a8d42e7cc2bd1 Mon Sep 17 00:00:00 2001 From: oitsjustjose Date: Wed, 11 Dec 2024 09:23:03 -0600 Subject: [PATCH] Buildtime updates --- BUILDING.md | 1 + Dockerfile | 9 +++++++++ requirements.txt | 13 ------------- src/server/pixlet.py | 14 +++++--------- 4 files changed, 15 insertions(+), 22 deletions(-) create mode 100644 BUILDING.md create mode 100644 Dockerfile diff --git a/BUILDING.md b/BUILDING.md new file mode 100644 index 0000000..3aa0771 --- /dev/null +++ b/BUILDING.md @@ -0,0 +1 @@ +sudo docker buildx build --platform linux/amd64,linux/arm64 -t oitsjustjose/tidbyt . diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c994e0c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.10-slim-bookworm + +RUN apt-get update && apt-get upgrade -y +# RUN apt-get install libc6 + +COPY . . +RUN pip install -r requirements.txt + +CMD ["fastapi", "run", "src/server/main.py"] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 7eb65d3..8f9847c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,12 +2,10 @@ annotated-types==0.7.0 anyio==4.7.0 async-generator==1.10 attrs==22.1.0 -beautifulsoup4==4.11.1 certifi==2022.9.24 cffi==1.15.1 charset-normalizer==2.1.1 click==8.1.7 -comtypes==1.1.14 dnspython==2.7.0 email_validator==2.2.0 exceptiongroup==1.2.2 @@ -15,7 +13,6 @@ fastapi==0.115.6 fastapi-cli==0.0.6 h11==0.14.0 httpcore==1.0.7 -httptools==0.6.4 httpx==0.28.1 idna==3.4 Jinja2==3.1.4 @@ -23,34 +20,24 @@ markdown-it-py==3.0.0 MarkupSafe==3.0.2 mdurl==0.1.2 outcome==1.2.0 -Pillow==9.3.0 pycparser==2.21 pydantic==2.10.3 pydantic_core==2.27.1 Pygments==2.18.0 -PySocks==1.7.1 python-dateutil==2.8.2 -python-dotenv==1.0.1 -python-multipart==0.0.19 -PyYAML==6.0.2 requests==2.28.1 rich==13.9.4 rich-toolkit==0.12.0 -selenium==4.6.0 shellingham==1.5.4 six==1.16.0 sniffio==1.3.0 sortedcontainers==2.4.0 -soupsieve==2.3.2.post1 starlette==0.41.3 trio==0.22.0 trio-websocket==0.9.2 typer==0.15.1 typing_extensions==4.12.2 urllib3==1.26.12 -uuid==1.30 uvicorn==0.32.1 -uvloop==0.21.0 watchfiles==1.0.3 -websockets==14.1 wsproto==1.2.0 diff --git a/src/server/pixlet.py b/src/server/pixlet.py index 14399ad..56dc2e5 100644 --- a/src/server/pixlet.py +++ b/src/server/pixlet.py @@ -1,6 +1,7 @@ """A Python Wrapper for Pixlet ops""" import subprocess +from os import getenv from pathlib import Path from platform import machine @@ -9,8 +10,9 @@ from renderables import Renderable class PixletHelper: def __init__(self): - self.root_path = Path("./").resolve() - self.pixlet = self.root_path.joinpath(f"pixlet.{machine()}").resolve() + self.root_path: Path = Path("./").resolve() + self.pixlet: Path = self.root_path.joinpath(f"pixlet.{machine()}").resolve() + self.device_id: str = getenv("TIDBYT_DEVICE_ID", "") def push_to_tidbyt(self, renderable: Renderable) -> None: """Pushes a renderable to the Tidbyt device @@ -42,19 +44,13 @@ class PixletHelper: Args: path (Path): The path to the given rendered webp """ - - with open( - self.root_path.joinpath("device_id").resolve(), "r", encoding="utf8" - ) as handle: - dev_id = handle.read() - with subprocess.Popen( [ self.pixlet, "push", "--installation-id", "automation", - dev_id, + self.device_id, str(path), ] ) as proc: