forked from winemug/omnipy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathomnipy_beacon.py
More file actions
24 lines (19 loc) · 774 Bytes
/
Copy pathomnipy_beacon.py
File metadata and controls
24 lines (19 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from socketserver import UDPServer, BaseRequestHandler
from podcomm.definitions import getLogger, configureLogging
class OmnipyBeacon(BaseRequestHandler):
def handle(self):
try:
data = self.request[0].strip()
socket = self.request[1]
host, port = self.client_address
getLogger().info("UDP broadcast message from %s: %s" % (host, data))
socket.sendto("wut".encode("ascii"), (host, 6665))
except Exception:
getLogger().exception("Error while responding to udp broadcast")
try:
configureLogging()
address = ("", 6664)
server = UDPServer(address, OmnipyBeacon)
server.serve_forever()
except Exception:
getLogger().exception("Error while running omnipy beacon")