feat: atxpi — server power & console manager (core, CLI, deploy)

- core/hardware: драйверы real (atxctl/pyserial) + mock, ATXPI_DRIVER
- core/power, console, mock: операции питания и RS232-консоли
- cli/atxpi: status/on/off/reset/cycle/console (stdlib, без deps)
- install.sh: one-shot curl|bash, идемпотентный, хост-агностичный
- deploy: systemd-юнит, шаблон env, update.sh
- README, AGENTS.md: документация и проектные решения
- AGENTS.md и доки очищены от внутренних хостов/адресов (публичный репо)
This commit is contained in:
toros
2026-09-08 21:54:11 +05:00
parent 135b091567
commit 12e6a453de
14 changed files with 657 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
"""Высокоуровневые операции RS232-консоли."""
from .hardware import make_console
def send(text: str) -> dict:
c = make_console()
c.open()
try:
c.send(text.encode("utf-8", errors="replace"))
return {"sent": text, "bytes": len(text.encode("utf-8", errors="replace"))}
finally:
c.close()
def read_bytes(timeout: float = 0.8) -> dict:
c = make_console()
c.open()
try:
data = c.read(timeout)
return {"bytes": len(data), "text": data.decode("utf-8", errors="replace")}
finally:
c.close()
def interact() -> dict:
"""Мини-интерактив: отправить строку и вернуть эхо/ответ."""
try:
import sys
return {"hint": "используйте `send` и `read_bytes` для скриптового интерактива"}
except Exception as e: # pragma: no cover
return {"error": str(e)}