AUTHORS: Mention Lucas De Marchi's contributions
[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         sys.exit(1)
9
10 bus = dbus.SystemBus()
11
12 manager = dbus.Interface(bus.get_object('net.connman', "/"),
13                                         'net.connman.Manager')
14
15 def technology_disable_tethering(path, tech_type):
16         tech = dbus.Interface(bus.get_object("net.connman", path),
17                                                 "net.connman.Technology")
18
19         properties = tech.GetProperties()
20
21         for key in properties.keys():
22                 if key in ["Type"]:
23                         if properties[key] == tech_type:
24                                 print "Disabling %s tethering" % tech_type
25                                 tech.SetProperty("Tethering", dbus.Boolean(0))
26
27                                 return tech_type
28                         else:
29                                 return None
30
31 technologies = manager.GetTechnologies()
32 tech = None
33
34 for path,_ in technologies:
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])