Skip to content

Commit 6a827a9

Browse files
author
Grigory Rylov
committed
fix(bot): use parent dir for git operations; fix memory display format
1 parent f7ddd7f commit 6a827a9

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

bot/gateway-restarter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def _run_git_command(*args, timeout: int = 30) -> Tuple[bool, str]:
398398
try:
399399
result = subprocess.run(
400400
["git"] + list(args),
401-
cwd=str(SCRIPT_DIR),
401+
cwd=str(SCRIPT_DIR.parent),
402402
capture_output=True,
403403
text=True,
404404
timeout=timeout,

bot/vk_longpoll.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -898,9 +898,9 @@ async def _get_sysmon_data(self) -> list:
898898
# Топ процесс
899899
if "processes" in data and data["processes"]:
900900
top_proc = data["processes"][0]
901-
mem = top_proc.get("memory", "N/A")
901+
mem_bytes = top_proc.get("memory_bytes", 0)
902902
mem_pct = top_proc.get("mem_pct", "0")
903-
lines.append(f"📈 Top: {mem} ({mem_pct}%)")
903+
lines.append(f"📈 Top: {_format_mib(mem_bytes // 1024 // 1024)} ({mem_pct}%)")
904904

905905
return lines
906906
except (asyncio.TimeoutError, aiohttp.ClientError, Exception):
@@ -1136,13 +1136,13 @@ async def _handle_sysmon_command(self, user_id: int):
11361136
if "processes" in data and data["processes"]:
11371137
lines.append("**📊 Топ процессов по памяти:**")
11381138
for i, proc in enumerate(data["processes"][:5], 1):
1139-
mem = proc.get("memory", "N/A")
1139+
mem_bytes = proc.get("memory_bytes", 0)
11401140
mem_pct = proc.get("mem_pct", "0")
11411141
cmd = proc.get("command", "")
11421142
# Обрезаем длинные команды
11431143
if len(cmd) > 60:
11441144
cmd = cmd[:57] + "..."
1145-
lines.append(f"{i}. {mem} ({mem_pct}%) - {cmd}")
1145+
lines.append(f"{i}. {_format_mib(mem_bytes // 1024 // 1024)} ({mem_pct}%) - {cmd}")
11461146

11471147
await self.vk.send_message(user_id, "\n".join(lines))
11481148
except asyncio.TimeoutError:

0 commit comments

Comments
 (0)