Initial Awawawa

This commit is contained in:
mueller_minki
2026-10-04 09:08:27 +02:00
commit 8e83a98ef4
76 changed files with 8225 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
"""Client for the patchbayd API socket (one request line, one JSON line back)."""
import json
import os
import socket
from flask import current_app
def request(cmd, timeout=3.0):
path = os.path.join(current_app.config["PB_CONF"].get("rundir"), "api.sock")
try:
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
s.settimeout(timeout)
s.connect(path)
s.sendall(cmd.encode() + b"\n")
data = b""
while not data.endswith(b"\n"):
chunk = s.recv(65536)
if not chunk:
break
data += chunk
return json.loads(data or b"{}")
except (OSError, ValueError) as e:
return {"ok": False, "error": f"daemon not reachable: {e}"}
def reload():
return request("RELOAD")