#!/usr/bin/env python3 # Copyright (c) 2026 Umber # # Licensed under the Apache License, Version 2.0; see LICENSE. # # Default: human summary — CPU, total PCIe sysfs count, Wi‑Fi-only table (+ chip from lspci -nn), # optional lspci -tv head, DMI hint. Use --pci-all for a second non-wireless “interesting” table. # Use --json for full machine output (large). from __future__ import annotations import argparse import json import sys from pathlib import Path _REPO = Path(__file__).resolve().parents[2] if str(_REPO / "src") not in sys.path: sys.path.insert(0, str(_REPO / "src")) from fiwicontrol.concentrator import ( ConcentratorPlatform, format_concentrator_platform_snapshot_human, ) def main() -> int: p = argparse.ArgumentParser(description=__doc__) p.add_argument("--label", default="default", help="Logical label (shown in human header only)") p.add_argument( "--proc-cpuinfo", type=Path, default=None, help="Override path (default: /proc/cpuinfo on Linux)", ) p.add_argument( "--no-host-probe", action="store_true", help="Skip lspci, sysfs PCIe links, and dmidecode (CPU fields only)", ) p.add_argument( "--pci-sysdir", type=Path, default=None, help="Override sysfs PCI devices dir (default: /sys/bus/pci/devices)", ) p.add_argument( "--json", action="store_true", help="Emit full JSON (verbose). Default is a short human report.", ) p.add_argument( "--pci-all", action="store_true", help="Human report: after Wi‑Fi table, add bridges / wide non-wireless links (capped by --pci-max-rows)", ) p.add_argument( "--pci-max-rows", type=int, default=40, metavar="N", help="Human report: max table rows (default 40)", ) p.add_argument( "--lspci-lines", type=int, default=18, metavar="N", help="Human report: first N lines of lspci -tv (0=omit; default 18)", ) args = p.parse_args() snap = ConcentratorPlatform(label=args.label).snapshot( proc_cpuinfo=args.proc_cpuinfo, host_probe=not args.no_host_probe, pci_devices_sysdir=args.pci_sysdir, ) if args.json: json.dump(snap.to_json_dict(), sys.stdout, indent=2) sys.stdout.write("\n") else: sys.stdout.write( format_concentrator_platform_snapshot_human( snap, label=args.label, pci_max_rows=max(1, args.pci_max_rows), lspci_max_lines=max(0, args.lspci_lines), include_pci_extra=args.pci_all, ) ) return 0 if __name__ == "__main__": raise SystemExit(main())