#!/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.ConnectionManager" not in properties["Interfaces"]: continue connman = dbus.Interface(bus.get_object('org.ofono', path), 'org.ofono.ConnectionManager') contexts = connman.GetContexts() for path, properties in contexts: connman.RemoveContext(path) print"Removed: [ %s ]" % (path)