test: Use session.Destroy()
[framework/connectivity/connman.git] / test / disable-tethering
1 #!/usr/bin/python
2
3 import sys
4 import dbus
5
6 if (len(sys.argv) < 2):
7         print "Usage: %s type" % (sys.argv[0])
8
9 bus = dbus.SystemBus()
10
11 manager = dbus.Interface(bus.get_object('net.connman', "/"),
12                                         'net.connman.Manager')
13
14 def technology_disable_tethering(path, tech_type):
15         tech = dbus.Interface(bus.get_object("net.connman", path),
16                                                 "net.connman.Technology")
17
18         properties = tech.GetProperties()
19
20         for key in properties.keys():
21                 if key in ["Type"]:
22                         if properties[key] == tech_type:
23                                 print "Disabling %s tethering" % tech_type
24                                 tech.SetProperty("Tethering", dbus.Boolean(0))
25
26                                 return tech_type
27                         else:
28                                 return None
29
30 properties = manager.GetProperties()
31
32 for key in properties.keys():
33         if key in ["Technologies"]:
34                 for path in properties[key]:
35                         tech = technology_disable_tethering(path, sys.argv[1])
36                         if tech != None:
37                                 break;
38
39 if tech == None:
40         print "Failed to disable %s tethering" % (sys.argv[1])