From da237ec616a3014225e13062171d46746578c29c Mon Sep 17 00:00:00 2001 From: h Date: Sun, 20 Sep 2026 18:26:05 +0000 Subject: [PATCH] =?UTF-8?q?refactor(hands):=20=D0=BB=D0=B8=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B5=20komodo=20=D1=81=D1=82=D0=B0=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=B8=D1=82=D1=81=D1=8F=20=D0=BF=D1=83=D0=B1=D0=BB?= =?UTF-8?q?=D0=B8=D1=87=D0=BD=D1=8B=D0=BC=20-=20=D0=B8=D0=BC=20=D1=85?= =?UTF-8?q?=D0=BE=D0=B4=D1=8F=D1=82=20=D0=B8=20=D0=B4=D0=B6=D0=BE=D0=B1?= =?UTF-8?q?=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- beaver_agent/hands/komodo.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/beaver_agent/hands/komodo.py b/beaver_agent/hands/komodo.py index 36ff3ee..b16c524 100644 --- a/beaver_agent/hands/komodo.py +++ b/beaver_agent/hands/komodo.py @@ -148,7 +148,7 @@ class Komodo: async def _status(self) -> str: servers, stacks = await asyncio.gather( - self._list("ListServers"), self._list("ListStacks") + self.listing("ListServers"), self.listing("ListStacks") ) lines = [f"{s['name']:24} {s['info']['state']}" for s in servers] bad = [s for s in stacks if s["info"]["state"] != "running"] @@ -165,7 +165,7 @@ class Komodo: return "\n".join(lines) async def _stacks(self) -> str: - stacks = await self._list("ListStacks") + stacks = await self.listing("ListStacks") lines = [] for s in sorted(stacks, key=lambda s: s["name"]): info = s["info"] @@ -181,11 +181,13 @@ class Komodo: async def _containers(self, server: str | None) -> str: names = ( - [server] if server else [s["name"] for s in await self._list("ListServers")] + [server] + if server + else [s["name"] for s in await self.listing("ListServers")] ) lines = [] for name in names: - containers = await self._list("ListDockerContainers", {"server": name}) + containers = await self.listing("ListDockerContainers", {"server": name}) lines.append(f"{name}:") lines.extend( f" {c['state']:10} {c['name']:36} {c.get('status', '')}" @@ -270,7 +272,7 @@ class Komodo: return out[:want], len(out) > want or page is not None async def _resource_names(self) -> dict[str, str]: - lists = await asyncio.gather(*(self._list(r) for r in RESOURCE_LISTS)) + lists = await asyncio.gather(*(self.listing(r) for r in RESOURCE_LISTS)) return {r["id"]: r["name"] for rows in lists for r in rows} async def _update(self, update_id: str) -> str: @@ -316,15 +318,21 @@ class Komodo: return f"{header}\n{self._clip(output.strip())}" async def _server_of(self, container: str) -> str | None: - for s in await self._list("ListServers"): - containers = await self._list("ListDockerContainers", {"server": s["name"]}) + for s in await self.listing("ListServers"): + containers = await self.listing( + "ListDockerContainers", {"server": s["name"]} + ) if any(c["name"] == container for c in containers): return s["name"] return None - async def _list( + async def listing( self, request: str, params: dict[str, Any] | None = None ) -> list[Any]: + """Любой ``List*`` целиком: страницами, пока Komodo не отдаст неполную. + + Публичная: этим же листанием ходят джобы, второго такого не пишем. + """ out: list[Any] = [] for page in range(LIST_PAGES): chunk = await self.read(