Skip to content

Commit 6b0d372

Browse files
committed
Simplified service constructors
1 parent 038855a commit 6b0d372

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/labthings/server/wsgi/gevent.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ def __init__(
4444

4545
def register_zeroconf(self):
4646
if self.labthing:
47+
# Get list of host addresses
48+
mdns_addresses = {
49+
socket.inet_aton(i)
50+
for i in get_all_addresses()
51+
if i not in ("127.0.0.1", "0.0.0.0")
52+
}
4753
# LabThing service
4854
self.service_infos.add(
4955
ServiceInfo(
@@ -56,11 +62,7 @@ def register_zeroconf(self):
5662
"description": self.labthing.description,
5763
"types": ";".join(self.labthing.types),
5864
},
59-
addresses={
60-
socket.inet_aton(i)
61-
for i in get_all_addresses()
62-
if i not in ("127.0.0.1", "0.0.0.0")
63-
},
65+
addresses=mdns_addresses,
6466
)
6567
)
6668
# Mozilla WebThing service
@@ -70,11 +72,7 @@ def register_zeroconf(self):
7072
f"{self.labthing.safe_title}._webthing._tcp.local.",
7173
port=self.port,
7274
properties={"path": self.labthing.url_prefix},
73-
addresses={
74-
socket.inet_aton(i)
75-
for i in get_all_addresses()
76-
if i not in ("127.0.0.1", "0.0.0.0")
77-
},
75+
addresses=mdns_addresses,
7876
)
7977
)
8078
self.zeroconf_server = Zeroconf(ip_version=IPVersion.V4Only)

0 commit comments

Comments
 (0)