"""Подбор правильного RCI-запроса для ширины канала.""" import json import sys import time from keenetic_client import Keenetic host = sys.argv[1] master = sys.argv[2] k = Keenetic(host, "admin", "73145146") k.auth() variants = [ {"interface": {master: {"channel-width": 20}}}, {"interface": {master: {"channel-width": "20"}}}, {"interface": {master: {"channel": {"width": 20}}}}, {"interface": {master: {"bandwidth": 20}}}, {"interface": {master: {"channel": {"width": "20"}}}}, ] for v in variants: st, hd, raw = k._req("POST", "/rci/", [v]) txt = raw[:120].decode("utf-8", "replace").replace("\n", " ") time.sleep(3) d = k.rci(f"/rci/show/interface/{master}") print(f" {json.dumps(v)[:70]:<72} st={st} bw={d.get('bandwidth')} {txt[:60]}") if str(d.get("bandwidth")) == "20": st2, _, _ = k._req("POST", "/rci/", [{"system": {"configuration": {"save": {}}}}]) print(" ✅ ширина 20, сохранено") break