OpenAgricultureFoundation / python-wifi-connect

Easy WiFi setup for Linux devices from your mobile phone or laptop
GNU General Public License v3.0
66 stars 47 forks source link

Dbus problem with non BalenOS #13

Closed cakebread closed 2 years ago

cakebread commented 3 years ago

I wasn't able to run this on Raspberry Pi OS (buster based).

./scripts/run.sh                                       
Address=192.168.42.1                                                       
Port=80                                      
UI path=/home/pi/python-wifi-connect/ui/                                 
Device registration code=                                                  
Delete Connections=False
Traceback (most recent call last):                                         
  File "/home/pi/python-wifi-connect/src/http_server.py", line 301, in <module>
    main(address, port, ui_path, rcode, delete_connections)              
  File "/home/pi/python-wifi-connect/src/http_server.py", line 204, in main
    ssids = netman.get_list_of_access_points()                                                                                                                                                                                              
  File "/home/pi/python-wifi-connect/src/netman.py", line 83, in get_list_of_access_points                                                                                                                                                  
    for dev in NetworkManager.NetworkManager.GetDevices():
  File "<string>", line 3, in GetDevices                  
  File "/home/pi/python-wifi-connect/venv/lib/python3.7/site-packages/NetworkManager.py", line 261, in proxy
    self._proxy = dbus.SystemBus().get_object(self.dbus_service, self.object_path, follow_name_owner_changes=True)
  File "/home/pi/python-wifi-connect/venv/lib/python3.7/site-packages/dbus/bus.py", line 225, in get_object
    self._require_main_loop()   # we don't get the signals otherwise
RuntimeError: To make asynchronous calls, receive signals or export objects, D-Bus connections must be attached to a main loop by passing mainloop=... to the constructor or calling dbus.set_default_main_loop(...)

When I add this to netmany.py it works great:

from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)

I don't know if this will break anything when using BalenaOS.

sazerzac commented 3 years ago

Not 100% sure this is related to your problem but this error is the same as a new / open issue on python-networkmanager.

https://github.com/seveas/python-networkmanager/issues/84

I ran into this issue on BalenaOS as well and can fix it either with the fix you used or by downgrading to python-networkmanager==2.1.

cakebread commented 3 years ago

Thanks, @sazerzac - I will try downgrading python-networkmanager and also try it on BalenaOS today or tomorrow and update with my results.