[STAGE5] Migrate PhotoBot to Tool Gateway with local tools
lint / hygiene (pull_request) Failing after 25s
standard / check (pull_request) Successful in 11s
lint / hygiene (push) Failing after 33s
standard / check (push) Successful in 12s

This commit is contained in:
architect committed 2026-11-29 22:05:34 +03:00
1 parent c0ec0d2d3d
commit 8844dabf94
5 files changed
+70 -2

No files matched your search

+13 -2
View File
@@ -1,3 +1,4 @@
import os
"""Флот ботов: у каждого свой домен и свои команды."""
import datetime
@@ -823,7 +824,12 @@ class PhotoBot(Bot):
self.cmd("space", "сколько занимает база фото")(lambda a: self._space())
def _stats(self):
c, err = local.ImmichDb().counts()
if os.environ.get("HUB_GATEWAY_PHOTO") == "1":
from .gateway import call
d = call("photo.stats")
c, err = d.get("counts"), d.get("error")
else:
c, err = local.ImmichDb().counts()
if err:
return f"Не смог прочитать базу Immich: {err}"
lines = ["**Фотографии**", "",
@@ -837,7 +843,12 @@ class PhotoBot(Bot):
return "\n".join(lines)
def _space(self):
out, err = local.pct_exec(151, ["su", "-", "postgres", "-c",
if os.environ.get("HUB_GATEWAY_PHOTO") == "1":
from .gateway import call
d = call("photo.space")
out, err = d.get("size"), d.get("error")
else:
out, err = local.pct_exec(151, ["su", "-", "postgres", "-c",
"psql -d immich_db -tAc \"select pg_size_pretty(pg_database_size('immich_db'))\""])
if err:
return f"Не удалось узнать размер: {err}"
+17
View File
@@ -0,0 +1,17 @@
"""Tiny client for the Buryans Tool Gateway."""
import json
import urllib.request
BASE = "http://127.0.0.1:9137"
def call(tool):
with urllib.request.urlopen(BASE + "/v1/call?tool=" + tool, timeout=25) as r:
d = json.loads(r.read().decode())
body = d.get("body")
if isinstance(body, str):
try:
return json.loads(body)
except Exception:
return {"raw": body}
return body or {}