dnsproxy: Only one copy of the relevant buffers will be made to a TCP request
[framework/connectivity/connman.git] / test / set-proxy
1 #!/usr/bin/python
2
3 import sys
4 import dbus
5
6 if (len(sys.argv) < 2):
7         print "Usage:"
8         print "%s <service> direct" % (sys.argv[0])
9         print "%s <service> manual [servers=uri1,uri2,...] [excludes=host1,host2,...]" % (sys.argv[0])
10         print "%s <service> auto url=[pac-url]" % (sys.argv[0])
11         print "Example: %s service0 manual servers=proxy.example.com:8080" % sys.argv[0]
12         print "         This would set the proxy uri and the method to manual"
13         sys.exit(1)
14
15 bus = dbus.SystemBus()
16 path = "/net/connman/service/" + sys.argv[1]
17 service = dbus.Interface(bus.get_object('net.connman', path),
18                                         'net.connman.Service')
19
20 values = { "Method" : sys.argv[2] }
21
22 properties = service.GetProperties()
23
24 for arg in sys.argv[3:]:
25         if arg.startswith("url="):
26                 url = arg.replace("url=", "", 1)
27                 values["URL"] = url
28         if arg.startswith("servers="):
29                 try:
30                         servers_uris = arg.replace("servers=","",1).split(",")
31                 except:
32                         servers_uris = []
33                 values["Servers"] = servers_uris
34         if arg.startswith("excludes="):
35                 try:
36                         excludes_uris = arg.replace("excludes=","",1).split(",")
37                 except:
38                         excludes_uris = []
39                 values["Excludes"] = excludes_uris
40
41 try:
42         service.SetProperty("Proxy.Configuration", dbus.Dictionary(values, signature='sv'))
43 except dbus.exceptions.DBusException, e_msg:
44         print e_msg