Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dark-Mute
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jess Ward
Dark-Mute
Commits
499ad77a
Commit
499ad77a
authored
6 years ago
by
Jess Ward
Browse files
Options
Downloads
Patches
Plain Diff
Get device mac addresses
parent
f03f39fb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
snap.py
+23
-3
23 additions, 3 deletions
snap.py
with
23 additions
and
3 deletions
snap.py
+
23
−
3
View file @
499ad77a
...
...
@@ -2,7 +2,7 @@ from zeroconf import ServiceBrowser, Zeroconf
import
snapcast.control
import
asyncio
import
ipaddress
#
import netifaces
import
netifaces
class
Scanner
:
...
...
@@ -43,11 +43,31 @@ def get_snapcast_server():
def
get_mac_addresses
():
pass
'''
Get list of all IPv4 MAC addresses for this device.
'''
def
contains_loopback
(
af_inet_addresses
):
'''
Check if list of IPv4 addresses contains loopback.
'''
for
ip
in
af_inet_addresses
:
if
ipaddress
.
IPv4Address
(
ip
[
'
addr
'
]).
is_loopback
:
return
True
return
False
mac_addresses
=
[]
for
interface
in
netifaces
.
interfaces
():
addresses
=
netifaces
.
ifaddresses
(
interface
)
# Skip interfaces without an IPv4 address
if
netifaces
.
AF_INET
not
in
addresses
:
continue
if
contains_loopback
(
addresses
[
netifaces
.
AF_INET
]):
continue
for
mac
in
addresses
[
netifaces
.
AF_LINK
]:
# Add to list if address has 'addr' key
if
mac
[
'
addr
'
]:
mac_addresses
.
append
(
mac
[
'
addr
'
])
return
mac_addresses
def
get_snapcast_client
(
server
):
'''
s
can through list of clients to find correct one
'''
'''
S
can through list of clients to find correct one
.
'''
for
client
in
server
.
clients
:
print
(
client
.
name
)
print
(
client
.
identifier
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment