#!/usr/bin/python3
from ubus import Ubus
ubus = Ubus('192.168.0.1')
ubus['session']['login'](username='root', password='xxx')
Result:
Traceback (most recent call last):
File "main.py", line 6, in <module>
ubus['session']['login'](username='root', password='xxx')
File "/home/tw/.local/share/virtualenvs/openwrt-wifi-presence-mqtt-L6rf1mrk/lib/python3.8/site-packages/ubus/protocol.py", line 259, in __getitem__
if item not in self.namespaces:
File "/home/tw/.local/share/virtualenvs/openwrt-wifi-presence-mqtt-L6rf1mrk/lib/python3.8/site-packages/ubus/protocol.py", line 247, in namespaces
self._ifaces = self._fetch_ifaces()
File "/home/tw/.local/share/virtualenvs/openwrt-wifi-presence-mqtt-L6rf1mrk/lib/python3.8/site-packages/ubus/protocol.py", line 251, in _fetch_ifaces
ifaces = {x: UbusNamespace(self, x) for x in self._do_request('list', '*', '')}
File "/home/tw/.local/share/virtualenvs/openwrt-wifi-presence-mqtt-L6rf1mrk/lib/python3.8/site-packages/ubus/protocol.py", line 242, in _do_request
raise UbusException("Got a non-200 retcode: %s" % res.status_code)
ubus.protocol.UbusException: Got a non-200 retcode: 404
Tested against openwrt-19.07:
Result: