2009-11-18 17:05:35 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import dbus
|
|
|
|
|
|
|
|
bus = dbus.SystemBus()
|
|
|
|
|
|
|
|
manager = dbus.Interface(bus.get_object('org.ofono', '/'),
|
|
|
|
'org.ofono.Manager')
|
|
|
|
|
2010-09-09 19:37:37 +00:00
|
|
|
modems = manager.GetModems()
|
2009-11-18 17:05:35 +00:00
|
|
|
|
2010-09-09 19:37:37 +00:00
|
|
|
for path, properties in modems:
|
2010-08-19 18:24:33 +00:00
|
|
|
if "org.ofono.ConnectionManager" not in properties["Interfaces"]:
|
2009-11-18 17:05:35 +00:00
|
|
|
continue
|
|
|
|
|
2010-08-19 18:24:33 +00:00
|
|
|
connman = dbus.Interface(bus.get_object('org.ofono', path),
|
|
|
|
'org.ofono.ConnectionManager')
|
2009-11-18 17:05:35 +00:00
|
|
|
|
2010-08-20 01:12:26 +00:00
|
|
|
contexts = connman.GetContexts()
|
2009-11-18 17:05:35 +00:00
|
|
|
|
2010-08-19 18:24:33 +00:00
|
|
|
if (len(contexts) == 0):
|
2009-11-18 17:05:35 +00:00
|
|
|
print "No context available"
|
|
|
|
sys.exit(1)
|
|
|
|
|
2010-10-21 19:44:51 +00:00
|
|
|
if len(sys.argv) > 1:
|
|
|
|
path = contexts[int(sys.argv[1])][0]
|
|
|
|
else:
|
|
|
|
path = contexts[0][0]
|
2009-11-18 17:05:35 +00:00
|
|
|
|
|
|
|
context = dbus.Interface(bus.get_object('org.ofono', path),
|
2010-08-19 18:24:33 +00:00
|
|
|
'org.ofono.ConnectionContext')
|
2009-11-18 17:05:35 +00:00
|
|
|
|
2010-04-16 19:42:27 +00:00
|
|
|
try:
|
|
|
|
context.SetProperty("Active", dbus.Boolean(0))
|
|
|
|
except dbus.DBusException, e:
|
|
|
|
print "Error activating %s: %s" % (path, str(e))
|
|
|
|
exit(2)
|