From 3841cda1cdcac470440b06838d56a2eb2256378c Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Fri, 10 May 2024 19:57:29 +0200 Subject: [PATCH] fix --- .envrc | 9 ++++++++- .gitignore | 1 + grzegorz/api.py | 2 +- grzegorz/mpv.py | 3 ++- grzegorz/nyasync.py | 4 ++-- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.envrc b/.envrc index b6c6c0e..93b6bdd 100644 --- a/.envrc +++ b/.envrc @@ -3,9 +3,11 @@ # It enters you into the poetry venv, removing the need for `poetry run`. if command -v nix >/dev/null; then - use nix -p poetry + use flake fi +export GRZEGORZ_IS_DEBUG=1 # mpv does not start in fullscreen + # Instead of using the flake, we use poetry to manage a development venv # We only use poetry2nix for deployment @@ -18,4 +20,9 @@ PATH_add "$VIRTUAL_ENV/bin" if ! command -v sanic >/dev/null; then poetry install + # patchelf the venv on nixos + if ! test -s /lib64/ld-linux-x86-64.so.2 || { uname -a | grep -qi nixos; }; then + #nix run github:GuillaumeDesforges/fix-python -- --venv "$VIRTUAL_ENV" #--libs .nix/libs.nix + fix-python --venv "$VIRTUAL_ENV" #--libs .nix/libs.nix + fi fi diff --git a/.gitignore b/.gitignore index c12bd80..32bddff 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ config.py *.socket result result-* +.direnv diff --git a/grzegorz/api.py b/grzegorz/api.py index 3a2ec72..754b0fc 100644 --- a/grzegorz/api.py +++ b/grzegorz/api.py @@ -47,7 +47,7 @@ PLAYLIST_DATA_CACHE = PlaylistDataCache(auto_fetch_data=True) @openapi.exclude(True) @response_text async def root(request: Request): - return "Hello friend, I hope you're having a lovely day" + return "Hello friend, I hope you're having a lovely day\n" @bp.post("/load") @openapi.summary("Add item to playlist") diff --git a/grzegorz/mpv.py b/grzegorz/mpv.py index 5e914dc..bdf9eef 100644 --- a/grzegorz/mpv.py +++ b/grzegorz/mpv.py @@ -9,6 +9,7 @@ from pathlib import Path from . import nyasync +IS_DEBUG = os.environ.get("GRZEGORZ_IS_DEBUG", "0") != "0" class MPV: # TODO: move this to /tmp or /var/run ? @@ -27,7 +28,7 @@ class MPV: f'--input-ipc-server={str(cls._ipc_endpoint)}', '--idle', '--force-window', - '--fullscreen', + *(('--fullscreen',) if not IS_DEBUG else ()), '--no-terminal', '--load-unsafe-playlists', '--keep-open', # Keep last frame of video on end of video diff --git a/grzegorz/nyasync.py b/grzegorz/nyasync.py index cc51ba4..1adb794 100644 --- a/grzegorz/nyasync.py +++ b/grzegorz/nyasync.py @@ -60,11 +60,11 @@ class UnixConnection: @classmethod async def from_path(cls, path): - endpoints = await asyncio.open_unix_connection(path) + endpoints = await asyncio.open_unix_connection(path, limit=2**24) # default is 2**16 return cls(*endpoints) def __aiter__(self): - return self.reader.__aiter__() + return self.reader.__aiter__() # readline def write(self, data): self.writer.write(data)