2 from threading
import Timer
7 UDPSock
= socket(AF_INET
, SOCK_DGRAM
)
8 UDPSock
.setsockopt(SOL_SOCKET
, SO_BROADCAST
, 1)
11 def add_service(self
, service
):
12 self
.services
.append(service
)
15 def format_services(self
):
16 return ';'.join(self
.services
)
18 def format_beacon(self
):
21 guid
= config
.getGUID()
23 beacon
.append('tivoconnect=1')
24 beacon
.append('swversion=1')
25 beacon
.append('method=broadcast')
26 beacon
.append('identity=%s' % guid
)
28 beacon
.append('machine=%s' % gethostname())
29 beacon
.append('platform=pc')
30 beacon
.append('services=' + self
.format_services())
32 return '\n'.join(beacon
)
34 def send_beacon(self
):
35 beacon_ips
= config
.getBeaconAddreses()
36 for beacon_ip
in beacon_ips
.split():
38 self
.UDPSock
.sendto(self
.format_beacon(), (beacon_ip
, 2190))
45 self
.timer
= Timer(60, self
.start
)
51 if __name__
== '__main__':
55 b
.add_service('TiVoMediaServer:9032/http')