python-sdbus / python-sdbus-networkmanager

python-sdbus binds for NetworkManager
GNU Lesser General Public License v2.1
30 stars 6 forks source link

Fix enum ConnectionType and use it in examples for testing #36

Closed bernhardkaindl closed 2 years ago

bernhardkaindl commented 2 years ago

Add a dictionary for getting the ConnectionType when having a DeviceType. Used for lookup of the available connections for a given device.

Update: Replaced with a fix for a small issue in the enum ConnectionType and a real-world example of it's use.

igo95862 commented 2 years ago

Hello,

I am pretty sure that getattr(ConnectionType, name) provides same functionality with no code duplication.

getattr(sdbus_async.networkmanager.ConnectionType, 'VETH') == 'veth'
# True
bernhardkaindl commented 2 years ago

@igo95862 Thanks! I noticed that a small fix is needed to make this work for Ethernet devices.

Please find the PR now updated to fix and use getattr(sdbus_async.networkmanager.ConnectionType, DeviceType(id).name) as suggested with thenetdevinfo` example updated to test it's use on real systems.

We added the enum sdbus_async.networkmanager.ConnectionType very recently, so it's not released yet and we can make this fix. I also checked my code and wasn't using ConnectionType.WIRED for anything yet.