[tv] recup_sap.py ++ on a l'info du groupe
This commit is contained in:
parent
f0908359b0
commit
b3b43c361a
1 changed files with 11 additions and 3 deletions
|
@ -19,6 +19,7 @@ mreq = struct.pack("4sl", socket.inet_aton(MCAST_GRP), socket.INADDR_ANY)
|
||||||
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
|
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
|
||||||
|
|
||||||
service={}
|
service={}
|
||||||
|
service_simple={}
|
||||||
|
|
||||||
start=time.time()
|
start=time.time()
|
||||||
while True:
|
while True:
|
||||||
|
@ -28,17 +29,24 @@ while True:
|
||||||
ip=None
|
ip=None
|
||||||
for line in msg[:-1]:
|
for line in msg[:-1]:
|
||||||
(tag, value) = line.split('=', 1)
|
(tag, value) = line.split('=', 1)
|
||||||
|
print (tag, value)
|
||||||
if tag=='s':
|
if tag=='s':
|
||||||
s=value
|
s=value
|
||||||
if tag=='c':
|
if tag=='c':
|
||||||
ip=value.split(' ')[2].split('/')[0]
|
ip=value.split(' ')[2].split('/')[0]
|
||||||
service[s]=ip
|
if tag=='a' and value.startswith('x-plgroup:'):
|
||||||
print "%s: %s" % (s, ip)
|
group=value[10:]
|
||||||
|
service_simple[s]=ip
|
||||||
|
try:
|
||||||
|
service[group][s]=ip
|
||||||
|
except KeyError:
|
||||||
|
service[group]={s:ip}
|
||||||
|
# print "%s: %s" % (s, ip)
|
||||||
if time.time() - start > timeout:
|
if time.time() - start > timeout:
|
||||||
break
|
break
|
||||||
|
|
||||||
f=open(path, 'w')
|
f=open(path, 'w')
|
||||||
l=service.items()
|
l=service_simple.items()
|
||||||
l.sort()
|
l.sort()
|
||||||
for (name, ip) in l:
|
for (name, ip) in l:
|
||||||
f.write("%s:%s\n" % (name, ip))
|
f.write("%s:%s\n" % (name, ip))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue