Fix python3 indentation

Signed-off-by: François Andriot <francois.andriot@thalesgroup.com>
pull/37/head r14.1.0
François Andriot 1 year ago
parent cde36fb6b3
commit b2b1acd415

@ -18,7 +18,7 @@ from string import split
publisher = None # SIGTERM handler must be able to reach this
class Publisher:
active = False
zeroconf = None
localip = None
@ -26,31 +26,29 @@ class Publisher:
def services(self): # override this to provide list of services to register
return []
def run(self):
def run(self):
self.localhostname = split(socket.gethostname(),'.')[0]+'.local.'
try:
self.localip = socket.gethostbyname(self.localhostname)
self.zeroconf = Zeroconf.Zeroconf(self.localip)
except:
return
self.active = True
try:
self.localip = socket.gethostbyname(self.localhostname)
self.zeroconf = Zeroconf.Zeroconf(self.localip)
except:
return
self.active = True
toRegister = self.services()
for i in toRegister:
service = Zeroconf.ServiceInfo(
i["type"]+".local.",
i["name"]+"."+i["type"]+".local.",
socket.inet_aton(self.localip),
i["port"],
0,
0,
i["properties"],
self.localhostname)
self.zeroconf.registerService(service)
i["type"]+".local.",
i["name"]+"."+i["type"]+".local.",
socket.inet_aton(self.localip),
i["port"],
0,
0,
i["properties"],
self.localhostname)
self.zeroconf.registerService(service)
def shutdown(self):
if self.active: self.zeroconf.close()

Loading…
Cancel
Save