Re: [PATCH v6 03/16] dundee: Add test scripts
Hi Wu, On 23.04.2012 12:13, Zheng, Wu wrote: Hi Daniel, I try to test your patches. Thanks for giving them a try. -Original Message- From: ofono-boun...@ofono.org [mailto:ofono-boun...@ofono.org] On Behalf Of Daniel Wagner Sent: Tuesday, April 03, 2012 12:20 AM To: ofono@ofono.org Cc: Daniel Wagner Subject: [PATCH v6 03/16] dundee: Add test scripts From: Daniel Wagner --- test/dundee-connect| 20 + test/dundee-disconnect | 20 + test/monitor-dundee| 109 3 files changed, 149 insertions(+) create mode 100755 test/dundee-connect create mode 100755 test/dundee-disconnect create mode 100755 test/monitor-dundee diff --git a/test/dundee-connect b/test/dundee-connect new file mode 100755 index 000..6cbc629 --- /dev/null +++ b/test/dundee-connect @@ -0,0 +1,20 @@ +#!/usr/bin/python + +import dbus +import sys + +bus = dbus.SystemBus() + +if len(sys.argv) == 2: + path = sys.argv[1] +else: + manager = dbus.Interface(bus.get_object('org.ofono.dundee', '/'), + 'org.ofono.dundee.Manager') + devices = manager.GetDevices() + path = devices[0][0] + +print "Connect device %s..." % path +device = dbus.Interface(bus.get_object('org.ofono.dundee', path), + 'org.ofono.dundee.Device') + +device.Connect() The dbus method connect() does not exist on org.ofono.dundee.Device, it cannot be found in device.c and doc/dundee-api.txt. Why? Best regards diff --git a/test/dundee-disconnect b/test/dundee-disconnect new file mode 100755 index 000..e67d8cd --- /dev/null +++ b/test/dundee-disconnect @@ -0,0 +1,20 @@ +#!/usr/bin/python + +import dbus +import sys + +bus = dbus.SystemBus() + +if len(sys.argv) == 2: + path = sys.argv[1] +else: + manager = dbus.Interface(bus.get_object('org.ofono.dundee', '/'), + 'org.ofono.dundee.Manager') + devices = manager.GetDevices() + path = devices[0][0] + +print "Disonnect device %s..." % path +device = dbus.Interface(bus.get_object('org.ofono.dundee', path), + 'org.ofono.dundee.Device') + +device.Disconnect() Change this line to device.SetProperty("Active", True) That should do the trick. The dbus method Disconnect() does not exist on org.ofono.dundee.Device, it cannot be found in device.c and doc/dundee-api.txt. Why? The documentation and the script are not in sync with the implementation. I'll fix that. Documentation change: Methods SetProperty() Test script change: device.SetProperty("Active", True) cheers, daniel ___ ofono mailing list ofono@ofono.org http://lists.ofono.org/listinfo/ofono
RE: [PATCH v6 03/16] dundee: Add test scripts
Hi Daniel, I try to test your patches. > -Original Message- > From: ofono-boun...@ofono.org [mailto:ofono-boun...@ofono.org] On Behalf > Of Daniel Wagner > Sent: Tuesday, April 03, 2012 12:20 AM > To: ofono@ofono.org > Cc: Daniel Wagner > Subject: [PATCH v6 03/16] dundee: Add test scripts > > From: Daniel Wagner > > --- > test/dundee-connect| 20 + > test/dundee-disconnect | 20 + > test/monitor-dundee| 109 > > 3 files changed, 149 insertions(+) > create mode 100755 test/dundee-connect > create mode 100755 test/dundee-disconnect create mode 100755 > test/monitor-dundee > > diff --git a/test/dundee-connect b/test/dundee-connect new file mode 100755 > index 000..6cbc629 > --- /dev/null > +++ b/test/dundee-connect > @@ -0,0 +1,20 @@ > +#!/usr/bin/python > + > +import dbus > +import sys > + > +bus = dbus.SystemBus() > + > +if len(sys.argv) == 2: > + path = sys.argv[1] > +else: > + manager = dbus.Interface(bus.get_object('org.ofono.dundee', '/'), > + 'org.ofono.dundee.Manager') > + devices = manager.GetDevices() > + path = devices[0][0] > + > +print "Connect device %s..." % path > +device = dbus.Interface(bus.get_object('org.ofono.dundee', path), > + 'org.ofono.dundee.Device') > + > +device.Connect() The dbus method connect() does not exist on org.ofono.dundee.Device, it cannot be found in device.c and doc/dundee-api.txt. Why? Best regards > diff --git a/test/dundee-disconnect b/test/dundee-disconnect new file mode > 100755 index 000..e67d8cd > --- /dev/null > +++ b/test/dundee-disconnect > @@ -0,0 +1,20 @@ > +#!/usr/bin/python > + > +import dbus > +import sys > + > +bus = dbus.SystemBus() > + > +if len(sys.argv) == 2: > + path = sys.argv[1] > +else: > + manager = dbus.Interface(bus.get_object('org.ofono.dundee', '/'), > + 'org.ofono.dundee.Manager') > + devices = manager.GetDevices() > + path = devices[0][0] > + > +print "Disonnect device %s..." % path > +device = dbus.Interface(bus.get_object('org.ofono.dundee', path), > + 'org.ofono.dundee.Device') > + > +device.Disconnect() The dbus method Disconnect() does not exist on org.ofono.dundee.Device, it cannot be found in device.c and doc/dundee-api.txt. Why? Best regards > diff --git a/test/monitor-dundee b/test/monitor-dundee new file mode 100755 > index 000..cf96ceb > --- /dev/null > +++ b/test/monitor-dundee > @@ -0,0 +1,109 @@ > +#!/usr/bin/python > + > +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:] > + 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" % (i
[PATCH v6 03/16] dundee: Add test scripts
From: Daniel Wagner --- test/dundee-connect| 20 + test/dundee-disconnect | 20 + test/monitor-dundee| 109 3 files changed, 149 insertions(+) create mode 100755 test/dundee-connect create mode 100755 test/dundee-disconnect create mode 100755 test/monitor-dundee diff --git a/test/dundee-connect b/test/dundee-connect new file mode 100755 index 000..6cbc629 --- /dev/null +++ b/test/dundee-connect @@ -0,0 +1,20 @@ +#!/usr/bin/python + +import dbus +import sys + +bus = dbus.SystemBus() + +if len(sys.argv) == 2: + path = sys.argv[1] +else: + manager = dbus.Interface(bus.get_object('org.ofono.dundee', '/'), + 'org.ofono.dundee.Manager') + devices = manager.GetDevices() + path = devices[0][0] + +print "Connect device %s..." % path +device = dbus.Interface(bus.get_object('org.ofono.dundee', path), + 'org.ofono.dundee.Device') + +device.Connect() diff --git a/test/dundee-disconnect b/test/dundee-disconnect new file mode 100755 index 000..e67d8cd --- /dev/null +++ b/test/dundee-disconnect @@ -0,0 +1,20 @@ +#!/usr/bin/python + +import dbus +import sys + +bus = dbus.SystemBus() + +if len(sys.argv) == 2: + path = sys.argv[1] +else: + manager = dbus.Interface(bus.get_object('org.ofono.dundee', '/'), + 'org.ofono.dundee.Manager') + devices = manager.GetDevices() + path = devices[0][0] + +print "Disonnect device %s..." % path +device = dbus.Interface(bus.get_object('org.ofono.dundee', path), + 'org.ofono.dundee.Device') + +device.Disconnect() diff --git a/test/monitor-dundee b/test/monitor-dundee new file mode 100755 index 000..cf96ceb --- /dev/null +++ b/test/monitor-dundee @@ -0,0 +1,109 @@ +#!/usr/bin/python + +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:] + 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, member, name) + +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)) + +def ussd(msg, member, path, interface): + iface = interface[interface.rfind(".") + 1:] + print "{%s} [%s] %s %s" % (iface, path, member, str(msg)) + +def value(value, member, path, interface): + iface = interface[interface.rfind(".") + 1:] + print "{%s} [%s] %s %s" % (iface, path, member, str(value)) + +if __name__ == '__main__': + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + + bus = dbus.SystemBus() + + bus.add_signal_receiver(property_changed, + bus_name="org.ofono.dundee", + signal_name = "PropertyChanged", + path_keyword="path", + interface_keyword="interface") + + bus.add_signal_receiver(a