Zalohovani vsech podstatnych souboru

This commit is contained in:
lachtan
2026-06-10 06:39:52 +02:00
parent 1e10891945
commit 67e29c8b88
69 changed files with 9115 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.11"
# dependencies = ["nanobot-ai"]
# ///
"""Check latest nanobot version from PyPI, GitHub releases, and Docker Hub."""
import importlib.metadata
import json
import sys
from urllib.error import URLError
from urllib.request import Request, urlopen
try:
CURRENT_VERSION = importlib.metadata.version("nanobot-ai")
except importlib.metadata.PackageNotFoundError:
CURRENT_VERSION = "unknown"
USER_AGENT = "nanobot-version-check/1.0"
def fetch_json(url: str, timeout: int = 10) -> dict | None:
req = Request(url, headers={"User-Agent": USER_AGENT})
try:
with urlopen(req, timeout=timeout) as resp:
return json.loads(resp.read())
except (URLError, json.JSONDecodeError, OSError) as e:
print(f" Error fetching {url}: {e}", file=sys.stderr)
return None
def check_pypi() -> str | None:
data = fetch_json("https://pypi.org/pypi/nanobot-ai/json")
if data:
return data.get("info", {}).get("version")
return None
def check_github() -> str | None:
data = fetch_json("https://api.github.com/repos/HKUDS/nanobot/releases/latest")
if data:
tag = data.get("tag_name", "")
return tag.lstrip("v") if tag else None
return None
def check_docker() -> str | None:
data = fetch_json("https://hub.docker.com/v2/repositories/smanx/nanobot/tags?page_size=10")
if data:
for tag in data.get("results", []):
name = tag.get("name", "")
if name and name != "latest":
return name
return None
def main():
print(f"Current nanobot version: {CURRENT_VERSION}")
pypi = check_pypi()
if pypi:
print(f"Latest PyPI version: {pypi}")
github = check_github()
if github:
print(f"Latest GitHub release: {github}")
docker = check_docker()
if docker:
print(f"Latest Docker Hub version tag: {docker}")
if __name__ == "__main__":
main()