rytilahti / python-ubus

Python library for accessing ubus over JSON-RPC
17 stars 9 forks source link

Not even login works #5

Open greuff opened 3 years ago

greuff commented 3 years ago

Tested against openwrt-19.07:

#!/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
rytilahti commented 3 years ago

It's been a while since I touched any of this, but have you installed uhttpd-mod-ubus and configured it as discussed in https://oldwiki.archive.openwrt.org/doc/techref/ubus#access_to_ubus_over_http ?`