--- test/monitor-connman | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/test/monitor-connman b/test/monitor-connman index cf8f7a6..4d44519 100755 --- a/test/monitor-connman +++ b/test/monitor-connman @@ -7,12 +7,54 @@ import dbus.mainloop.glib from dbus.lowlevel import MethodCallMessage, HANDLER_RESULT_NOT_YET_HANDLED -def property_changed(name, value, path, interface): - iface = interface[interface.rfind(".") + 1:] +def extract_list(list): + val = "[" + for i in list: + if type(i).__name__ == 'Dictionary': + val = extract_values(i) + else: + val += " " + str(i) + val += " ]" + return val + +def extract_values(values): + val = "{" + for key in values.keys(): + val += " " + key + "=" + if key in ["PrefixLength"]: + val += "%s" % (int(values[key])) + elif key in ["IPv4", "IPv6", "Ethernet" ]: + val += extract_values(values[key]) + elif key in [ "AllowedBearers" ]: + val += extract_list(values[key]) + else: + if key in ["Servers", "Excludes"]: + val += extract_list(values[key]) + else: + val += str(values[key]) + val += " }" + return val + +def extract(name, value): + val = None + if name in ["Strength", "Priority"]: val = int(value) + elif name in ["IPv4", "IPv6", "Ethernet", "Proxy" ]: + val = extract_values(value) + elif name in ["Nameservers", "Domains", "Services", + "Update", "Technologies", "AvailableTechnologies", + "EnabledTechnologies", "ConnectedTechnologies" ]: + val = extract_list(value) else: val = str(value) + + return val + +def property_changed(name, value, path, interface): + iface = interface[interface.rfind(".") + 1:] + val = extract(name, value) + print "{%s} [%s] %s = %s" % (iface, path, name, val) def message_filter(connection, message): @@ -42,4 +84,5 @@ if __name__ == '__main__': bus.add_message_filter(message_filter) mainloop = gobject.MainLoop() + mainloop.run() -- 1.7.3.4 _______________________________________________ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman