Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Anders Blomdell
hostinfo
Commits
7cf2c93a
Commit
7cf2c93a
authored
Nov 04, 2021
by
Anders Blomdell
Browse files
Make device matching work for unknown device kinds
parent
0325467f
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/hostinfo/networkmanager.py
View file @
7cf2c93a
...
...
@@ -28,25 +28,32 @@ class Network(object):
self
.
_tun
=
{}
self
.
_connection
=
{}
# Get devices from network manager
def
is_kind
(
device
,
kind
):
device_class
=
getattr
(
NetworkManager
,
kind
,
None
)
if
device_class
==
None
:
print
(
'%s not defined in this version of NetworkManager'
%
kind
)
return
False
return
isinstance
(
device
,
device_class
)
for
d
in
NetworkManager
.
NetworkManager
.
AllDevices
:
if
is
instance
(
d
,
NetworkManager
.
Generic
):
if
is
_kind
(
d
,
'
Generic
'
):
pass
elif
is
instance
(
d
,
NetworkManager
.
Dummy
):
elif
is
_kind
(
d
,
'
Dummy
'
):
pass
elif
is
instance
(
d
,
NetworkManager
.
Wireless
):
elif
is
_kind
(
d
,
'
Wireless
'
):
pass
elif
is
instance
(
d
,
NetworkManager
.
WireGuard
):
elif
is
_kind
(
d
,
'
WireGuard
'
):
pass
elif
is
instance
(
d
,
NetworkManager
.
Wired
):
elif
is
_kind
(
d
,
'
Wired
'
):
self
.
_wired
[
d
.
HwAddress
.
lower
()]
=
d
pass
elif
is
instance
(
d
,
NetworkManager
.
Bridge
):
elif
is
_kind
(
d
,
'
Bridge
'
):
self
.
_bridge
[
d
.
HwAddress
.
lower
()]
=
d
pass
elif
is
instance
(
d
,
NetworkManager
.
IPTunnel
):
elif
is
_kind
(
d
,
'
IPTunnel
'
):
self
.
_ip_tunnel
[
d
.
Interface
]
=
d
pass
elif
is
instance
(
d
,
NetworkManager
.
Tun
):
elif
is
_kind
(
d
,
'
Tun
'
):
self
.
_tun
[
d
.
Interface
]
=
d
pass
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment