X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-utils%2Favahi-discover.in;h=00a56023cd1712921648915a7337aa882491ffd1;hb=56d97acfa37cbf4cfe2a038f76dcc00ea63c9149;hp=1083b6ca9d66bffc6abc756c6c42d7eea1cf0580;hpb=1231d2977ff2f5a19b3d9d74271085633ef6e341;p=catta
diff --git a/avahi-utils/avahi-discover.in b/avahi-utils/avahi-discover.in
index 1083b6c..00a5602 100755
--- a/avahi-utils/avahi-discover.in
+++ b/avahi-utils/avahi-discover.in
@@ -73,12 +73,7 @@ class Main_window(SimpleGladeApp):
print "\tHost %s (%s), port %i, TXT data: %s" % (host, address, port, str(avahi.txt_array_to_string_array(txt)))
- if len(txt) == 0:
- txt_data = "empty"
- else:
- txt_data = str(avahi.txt_array_to_string_array(txt))
-
- self.update_label(interface, protocol, name, stype, domain, host, aprotocol, address, port, txt_data)
+ self.update_label(interface, protocol, name, stype, domain, host, aprotocol, address, port, avahi.txt_array_to_string_array(txt))
def print_error(self, err):
error_label = "Error: %s" % (err)
@@ -172,8 +167,28 @@ class Main_window(SimpleGladeApp):
if domain != "local":
self.browse_domain(interface, protocol, domain)
+ def pair_to_dict(self, l):
+ res = dict()
+ for el in l:
+ if "=" not in el:
+ res[el]=''
+ else:
+ tmp = el.split('=',1)
+ if len(tmp[0]) > 0:
+ res[tmp[0]] = tmp[1]
+ return res
+
+
def update_label(self,interface, protocol, name, stype, domain, host, aprotocol, address, port, txt):
- infos = "Service Type: %s\nService Name: %s\nDomain Name: %s\nInterface: %s %s\nAddress: %s/%s:%i\nTXT Data: %s" % (stype, name, domain, self.siocgifname(interface), self.protoname(protocol), host, address, port, str(txt))
+ if len(txt) != 0:
+ txts = ""
+ txtd = self.pair_to_dict(txt)
+ for k,v in txtd.items():
+ txts+="TXT %s = %s\n" % (k,v)
+ else:
+ txts = "TXT Data: empty"
+
+ infos = "Service Type: %s\nService Name: %s\nDomain Name: %s\nInterface: %s %s\nAddress: %s/%s:%i\n%s" % (stype, name, domain, self.siocgifname(interface), self.protoname(protocol), host, address, port, txts.strip())
self.info_label.set_markup(infos)
def insert_row(self, model,parent,