Closed vanities closed 3 years ago
>>> NetworkManager.NetworkManager.GetDeviceByIpIface('wlan0')
>>>
>>> NetworkManager.NetworkManager.GetDeviceByIpIface('p2p-dev-wlan0')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 9, in GetDeviceByIpIface
File "/usr/lib/python3.7/site-packages/NetworkManager.py", line 550, in to_python
val = fixups.base_to_python(val)
File "/usr/lib/python3.7/site-packages/NetworkManager.py", line 620, in base_to_python
return globals()[classname](val)
File "/usr/lib/python3.7/site-packages/NetworkManager.py", line 348, in __new__
klass = device_class(obj.Get('org.freedesktop.NetworkManager.Device', 'DeviceType', dbus_interface='org.freedesktop.DBus.Properties'))
File "/usr/lib/python3.7/site-packages/NetworkManager.py", line 393, in device_class
}[typ]
KeyError: dbus.UInt32(30, variant_level=1)
Python 3.7.3 (default, May 11 2019, 00:38:04)
[GCC 9.1.1 20190503 (Red Hat 9.1.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from NetworkManager import *
>>> NetworkManager.GetAllDevices()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 8, in GetAllDevices
File "/home/cwells/.local/lib/python3.7/site-packages/NetworkManager.py", line 550, in to_python
val = fixups.base_to_python(val)
File "/home/cwells/.local/lib/python3.7/site-packages/NetworkManager.py", line 607, in base_to_python
return [fixups.base_to_python(x) for x in val]
File "/home/cwells/.local/lib/python3.7/site-packages/NetworkManager.py", line 607, in <listcomp>
return [fixups.base_to_python(x) for x in val]
File "/home/cwells/.local/lib/python3.7/site-packages/NetworkManager.py", line 620, in base_to_python
return globals()[classname](val)
File "/home/cwells/.local/lib/python3.7/site-packages/NetworkManager.py", line 348, in __new__
klass = device_class(obj.Get('org.freedesktop.NetworkManager.Device', 'DeviceType', dbus_interface='org.freedesktop.DBus.Properties'))
File "/home/cwells/.local/lib/python3.7/site-packages/NetworkManager.py", line 393, in device_class
}[typ]
KeyError: dbus.UInt32(30, variant_level=1)
>>>
I have the same error on Fedora 30
> $ nmcli device
DEVICE TYPE STATE CONNECTION
wlp2s0 wifi connecté ****
p2p-dev-wlp2s0 wifi-p2p déconnecté --
enp0s31f6 ethernet indisponible --
docker0 bridge non-géré --
lo loopback non-géré --
> $ python3
Python 3.7.3 (default, May 11 2019, 00:38:04)
[GCC 9.1.1 20190503 (Red Hat 9.1.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import NetworkManager
>>> NetworkManager.NetworkManager.GetDeviceByIpIface('wlp2s0')
<NetworkManager.Wireless object at 0x7f3c1fdbd2b0>
>>> NetworkManager.NetworkManager.GetDeviceByIpIface('enp0s31f6')
<NetworkManager.Wired object at 0x7f3c1fd4bfd0>
>>> NetworkManager.NetworkManager.GetDeviceByIpIface('p2p-dev-wlp2s0')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 9, in GetDeviceByIpIface
File "/usr/lib/python3.7/site-packages/NetworkManager.py", line 550, in to_python
val = fixups.base_to_python(val)
File "/usr/lib/python3.7/site-packages/NetworkManager.py", line 620, in base_to_python
return globals()[classname](val)
File "/usr/lib/python3.7/site-packages/NetworkManager.py", line 348, in __new__
klass = device_class(obj.Get('org.freedesktop.NetworkManager.Device', 'DeviceType', dbus_interface='org.freedesktop.DBus.Properties'))
File "/usr/lib/python3.7/site-packages/NetworkManager.py", line 393, in device_class
}[typ]
KeyError: dbus.UInt32(30, variant_level=1)
>>>
Have the same problem with this device. I think a broader solution is to not crash if you don't find something, but instead send a UNKNOWN CODE or None for anything you don't recognize. Also, I just checked on version 2.1 of python-networkmanager, the patch for WIFI_P2P is missing for Python3.7 and Python3.6.
I have "fixed" it with this workaround in init, by addding a default type:
def device_class(typ):
return {
NM_DEVICE_TYPE_ADSL: Adsl,
NM_DEVICE_TYPE_BOND: Bond,
NM_DEVICE_TYPE_BRIDGE: Bridge,
NM_DEVICE_TYPE_BT: Bluetooth,
NM_DEVICE_TYPE_ETHERNET: Wired,
NM_DEVICE_TYPE_GENERIC: Generic,
NM_DEVICE_TYPE_INFINIBAND: Infiniband,
NM_DEVICE_TYPE_IP_TUNNEL: IPTunnel,
NM_DEVICE_TYPE_MACVLAN: Macvlan,
NM_DEVICE_TYPE_MODEM: Modem,
NM_DEVICE_TYPE_OLPC_MESH: OlpcMesh,
NM_DEVICE_TYPE_TEAM: Team,
NM_DEVICE_TYPE_TUN: Tun,
NM_DEVICE_TYPE_VETH: Veth,
NM_DEVICE_TYPE_VLAN: Vlan,
NM_DEVICE_TYPE_VXLAN: Vxlan,
NM_DEVICE_TYPE_WIFI: Wireless,
NM_DEVICE_TYPE_WIMAX: Wimax,
NM_DEVICE_TYPE_MACSEC: MacSec,
NM_DEVICE_TYPE_DUMMY: Dummy,
NM_DEVICE_TYPE_PPP: PPP,
NM_DEVICE_TYPE_OVS_INTERFACE: OvsIf,
NM_DEVICE_TYPE_OVS_PORT: OvsPort,
NM_DEVICE_TYPE_OVS_BRIDGE: OvsBridge
}.get(typ,Generic)
Which lets me see a device '/virtual/device/placeholder/1', which I imagine to be the problem. I don't really understand the cause of the error, but this fix seems somewhat reasonable.
Can we merge the above PR in so that python-networkmanager can work for devices with wifi-p2p in nmcli device?
I am still getting this error even though the fix was added. Someone has any idea why?
NetworkManager.NetworkManager.Version '8.6.0.12-1.22.16'
devices = NetworkManager.GetAllDevices()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 8, in GetAllDevices
File "/usr/lib/python3.8/site-packages/NetworkManager.py", line 550, in to_python
val = fixups.base_to_python(val)
File "/usr/lib/python3.8/site-packages/NetworkManager.py", line 607, in base_to_python
return [fixups.base_to_python(x) for x in val]
File "/usr/lib/python3.8/site-packages/NetworkManager.py", line 607, in <listcomp>
return [fixups.base_to_python(x) for x in val]
File "/usr/lib/python3.8/site-packages/NetworkManager.py", line 620, in base_to_python
return globals()[classname](val)
File "/usr/lib/python3.8/site-packages/NetworkManager.py", line 348, in __new__
klass = device_class(obj.Get('org.freedesktop.NetworkManager.Device', 'DeviceType', dbus_interface='org.freedesktop.DBus.Properties'))
File "/usr/lib/python3.8/site-packages/NetworkManager.py", line 368, in device_class
return {
KeyError: dbus.UInt32(30, variant_level=1)
Getting this error ever since upgrading my network card.
nmcli d
shows me this:I think it may have something to do with
p2p-dev-wlan0
?Here's the error when I try to get devices: