* [PATCH 1/2] monitor-ofono: deep pretty-print @ 2010-08-25 11:57 Pekka.Pessi 2010-08-25 11:57 ` [PATCH 2/2] test-monitor: monitor irregular signals Pekka.Pessi 2010-08-25 16:48 ` [PATCH 1/2] monitor-ofono: deep pretty-print Denis Kenzior 0 siblings, 2 replies; 4+ messages in thread From: Pekka.Pessi @ 2010-08-25 11:57 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 2101 bytes --] From: Pekka Pessi <Pekka.Pessi@nokia.com> --- test/monitor-ofono | 60 +++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 46 insertions(+), 14 deletions(-) diff --git a/test/monitor-ofono b/test/monitor-ofono index a441d5d..94febac 100755 --- a/test/monitor-ofono +++ b/test/monitor-ofono @@ -5,22 +5,54 @@ import gobject import dbus import dbus.mainloop.glib +_dbus2py = { + dbus.String : unicode, + dbus.UInt32 : int, + dbus.Int32 : int, + dbus.Int16 : int, + dbus.UInt16 : int, + dbus.UInt64 : int, + dbus.Int64 : int, + dbus.Byte : int, + dbus.Boolean : bool, + dbus.ByteArray : str, + dbus.ObjectPath : str + } + +def dbus2py(d): + t = type(d) + if t in _dbus2py: + return _dbus2py[t](d) + if t is dbus.Dictionary: + return dict([(dbus2py(k), dbus2py(v)) for k, v in d.items()]) + if t is dbus.Array and d.signature == "y": + return "".join([chr(b) for b in d]) + if t is dbus.Array or t is list: + return [dbus2py(v) for v in d] + if t is dbus.Struct or t is tuple: + return tuple([dbus2py(v) for v in d]) + return d + +def pretty(d): + d = dbus2py(d) + t = type(d) + + if t in (dict, tuple, list) and len(d) > 0: + if t is dict: + d = ", ".join(["%s = %s" % (k, pretty(v)) + for k, v in d.items()]) + return "{ %s }" % d + + d = " ".join([pretty(e) for e in d]) + + if t is tuple: + return "( %s )" % d + + return str(d) + def property_changed(name, value, path, interface): iface = interface[interface.rfind(".") + 1:] - if name in ["Modems", "Interfaces", "Features", - "Technologies", - "SubscriberNumbers", - "EmergencyNumbers", - "PreferredLanguages"]: - val = "" - for i in value: - val += i + " " - elif name in ["MobileNetworkCodeLength", - "VoicemailMessageCount"]: - val = int(value) - else: - val = str(value) - print "{%s} [%s] %s = %s" % (iface, path, name, val) + print "{%s} [%s] %s = %s" % (iface, path, name, pretty(value)) if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] test-monitor: monitor irregular signals 2010-08-25 11:57 [PATCH 1/2] monitor-ofono: deep pretty-print Pekka.Pessi @ 2010-08-25 11:57 ` Pekka.Pessi 2010-08-25 16:48 ` Denis Kenzior 2010-08-25 16:48 ` [PATCH 1/2] monitor-ofono: deep pretty-print Denis Kenzior 1 sibling, 1 reply; 4+ messages in thread From: Pekka.Pessi @ 2010-08-25 11:57 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 2862 bytes --] From: Pekka Pessi <Pekka.Pessi@nokia.com> --- test/monitor-ofono | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 63 insertions(+), 0 deletions(-) diff --git a/test/monitor-ofono b/test/monitor-ofono index 94febac..86239eb 100755 --- a/test/monitor-ofono +++ b/test/monitor-ofono @@ -54,6 +54,23 @@ def property_changed(name, value, path, interface): iface = interface[interface.rfind(".") + 1:] print "{%s} [%s] %s = %s" % (iface, path, name, pretty(value)) +def added(name, value, member, path, interface): + iface = interface[interface.rfind(".") + 1:] + print "{%s} [%s] %s %s" % (iface, member, name, pretty(value)) + +def removed(name, member, path, interface): + iface = interface[interface.rfind(".") + 1:] + print "{%s} [%s] %s" % (iface, name, member) + +def event(member, path, interface): + iface = interface[interface.rfind(".") + 1:] + print "{%s} [%s] %s" % (iface, path, member) + +def message(msg, args, member, path, interface): + iface = interface[interface.rfind(".") + 1:] + print "{%s} [%s] %s %s (%s)" % (iface, path, member, + str(msg), pretty(args)) + if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) @@ -65,5 +82,51 @@ if __name__ == '__main__': path_keyword="path", interface_keyword="interface") + for member in ["IncomingBarringInEffect", + "OutgoingBarringInEffect", + "NearMaximumWarning"]: + bus.add_signal_receiver(event, + bus_name="org.ofono", + signal_name = member, + member_keyword="member", + path_keyword="path", + interface_keyword="interface") + + bus.add_signal_receiver(added, + bus_name="org.ofono", + signal_name = "ContextAdded", + member_keyword="member", + path_keyword="path", + interface_keyword="interface") + + bus.add_signal_receiver(removed, + bus_name="org.ofono", + signal_name = "ContextRemoved", + member_keyword="member", + path_keyword="path", + interface_keyword="interface") + + bus.add_signal_receiver(added, + bus_name="org.ofono", + signal_name = "CallAdded", + member_keyword="member", + path_keyword="path", + interface_keyword="interface") + bus.add_signal_receiver(removed, + bus_name="org.ofono", + signal_name = "CallRemoved", + member_keyword="member", + path_keyword="path", + interface_keyword="interface") + + for member in ["IncomingBroadcast", "EmergencyBroadcast", + "IncomingMessage", "ImmediateMessage"]: + bus.add_signal_receiver(message, + bus_name="org.ofono", + signal_name = member, + member_keyword="member", + path_keyword="path", + interface_keyword="interface") + mainloop = gobject.MainLoop() mainloop.run() -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] test-monitor: monitor irregular signals 2010-08-25 11:57 ` [PATCH 2/2] test-monitor: monitor irregular signals Pekka.Pessi @ 2010-08-25 16:48 ` Denis Kenzior 0 siblings, 0 replies; 4+ messages in thread From: Denis Kenzior @ 2010-08-25 16:48 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 321 bytes --] Hi Pekka, On 08/25/2010 06:57 AM, Pekka.Pessi(a)nokia.com wrote: > From: Pekka Pessi <Pekka.Pessi@nokia.com> > > --- > test/monitor-ofono | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 63 insertions(+), 0 deletions(-) > Patch has been applied, thanks. Regards, -Denis ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] monitor-ofono: deep pretty-print 2010-08-25 11:57 [PATCH 1/2] monitor-ofono: deep pretty-print Pekka.Pessi 2010-08-25 11:57 ` [PATCH 2/2] test-monitor: monitor irregular signals Pekka.Pessi @ 2010-08-25 16:48 ` Denis Kenzior 1 sibling, 0 replies; 4+ messages in thread From: Denis Kenzior @ 2010-08-25 16:48 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 321 bytes --] Hi Pekka, On 08/25/2010 06:57 AM, Pekka.Pessi(a)nokia.com wrote: > From: Pekka Pessi <Pekka.Pessi@nokia.com> > > --- > test/monitor-ofono | 60 +++++++++++++++++++++++++++++++++++++++------------ > 1 files changed, 46 insertions(+), 14 deletions(-) > Patch has been applied, thanks. Regards, -Denis ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-08-25 16:48 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-08-25 11:57 [PATCH 1/2] monitor-ofono: deep pretty-print Pekka.Pessi 2010-08-25 11:57 ` [PATCH 2/2] test-monitor: monitor irregular signals Pekka.Pessi 2010-08-25 16:48 ` Denis Kenzior 2010-08-25 16:48 ` [PATCH 1/2] monitor-ofono: deep pretty-print Denis Kenzior
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.