Initial commit

This commit is contained in:
Nikita Tyukalov, ASUS, Linux
2026-07-19 22:02:06 +03:00
commit 2bc979c9b4
9 changed files with 811 additions and 0 deletions

25
tools/builtin.py Normal file
View File

@@ -0,0 +1,25 @@
"""
This module implements some builtin tools.
"""
import asyncio
import sys
from typing import Literal
async def builtin_network_ping(host: str) -> str:
"""Ping `host` to check if it is reachable."""
try:
param = '-n' if sys.platform.lower() == 'windows' else '-c'
cmd = ['ping', param, '1', host]
process = await asyncio.create_subprocess_exec(
*cmd,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE
)
stdout, stderr = await process.communicate()
if process.returncode == 0:
return f"{host} is reachable"
else:
return f"{host} is unreachable"
except Exception as e:
return f"Exception happened: {e}"