diff --git a/test/activate-context b/test/activate-context index 7ee60e54..98c177a6 100755 --- a/test/activate-context +++ b/test/activate-context @@ -35,4 +35,8 @@ for path in properties["Modems"]: context = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.PrimaryDataContext') - context.SetProperty("Active", dbus.Boolean(1)) + try: + context.SetProperty("Active", dbus.Boolean(1)) + except dbus.DBusException, e: + print "Error activating %s: %s" % (path, str(e)) + exit(2) diff --git a/test/create-context b/test/create-context index 08f29600..46b9d620 100755 --- a/test/create-context +++ b/test/create-context @@ -32,6 +32,10 @@ for path in properties["Modems"]: context = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.PrimaryDataContext') - context.SetProperty("AccessPointName", sys.argv[1]) + try: + context.SetProperty("AccessPointName", sys.argv[1]) + except IndexError: + print "Usage: %s " % sys.argv[0] + exit(1) print "Setting APN of %s to %s" % (path, sys.argv[1]) diff --git a/test/deactivate-context b/test/deactivate-context index 2e119219..23d2c0c5 100755 --- a/test/deactivate-context +++ b/test/deactivate-context @@ -33,4 +33,8 @@ for path in properties["Modems"]: context = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.PrimaryDataContext') - context.SetProperty("Active", dbus.Boolean(0)) + try: + context.SetProperty("Active", dbus.Boolean(0)) + except dbus.DBusException, e: + print "Error activating %s: %s" % (path, str(e)) + exit(2) diff --git a/test/remove-contexts b/test/remove-contexts new file mode 100755 index 00000000..181c6fcd --- /dev/null +++ b/test/remove-contexts @@ -0,0 +1,28 @@ +#!/usr/bin/python + +import dbus + +bus = dbus.SystemBus() + +manager = dbus.Interface(bus.get_object('org.ofono', '/'), + 'org.ofono.Manager') + +properties = manager.GetProperties() + +for path in properties["Modems"]: + modem = dbus.Interface(bus.get_object('org.ofono', path), + 'org.ofono.Modem') + + properties = modem.GetProperties() + + if "org.ofono.DataConnectionManager" not in properties["Interfaces"]: + continue + + connmgr = dbus.Interface(bus.get_object('org.ofono', path), + 'org.ofono.DataConnectionManager') + + properties = connmgr.GetProperties() + + for path in properties["PrimaryContexts"]: + connmgr.RemoveContext(path) + print"Removed: [ %s ]" % (path)