---
test/set-proxy | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 80 insertions(+), 0 deletions(-)
create mode 100755 test/set-proxy
diff --git a/test/set-proxy b/test/set-proxy
new file mode 100755
index 0000000..b081c67
--- /dev/null
+++ b/test/set-proxy
@@ -0,0 +1,80 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+if (len(sys.argv) < 2):
+ print "Usage: %s <service> [direct|auto|manual|auto-config]
[url=pac-url] [http=host:port] [https=host:port] [ftp=host:port]
[socks=host:port] [rtsp=host:port] ignore=host1,host2,...]" % (sys.argv[0])
+ print "Example: %s service0 manual http=http.proxy.example.com:8080
rtsp=" % sys.argv[0]
+ print " This would set the http proxy and clear the rtsp proxy
values"
+ print "Note that trying to set method to 'auto-config' should fail."
+ sys.exit(1)
+
+bus = dbus.SystemBus()
+path = "/profile/default/" + sys.argv[1]
+service = dbus.Interface(bus.get_object('org.moblin.connman', path),
+ 'org.moblin.connman.Service')
+
+print service
+
+values = { "Method" : sys.argv[2] }
+
+properties = service.GetProperties()
+
+for arg in sys.argv[3:]:
+ if arg.startswith("url="):
+ url = arg.replace("url=", "", 1)
+ #print "url: %s" % url
+ values["URL"] = url
+ if arg.startswith("http="):
+ try:
+ (host, port) = arg.replace("http=","",1).split(":")
+ except:
+ (host, port) = ("", 0)
+ #print "http: %s:%s" % (host, port)
+ values["Http"] = host
+ values["HttpPort"] = dbus.UInt16(port)
+ if arg.startswith("https="):
+ try:
+ (host, port) = arg.replace("https=","",1).split(":")
+ except:
+ (host, port) = ("", 0)
+ #print "https: %s:%s" % (host, port)
+ values["Https"] = host
+ values["HttpsPort"] = dbus.UInt16(port)
+ if arg.startswith("ftp="):
+ try:
+ (host, port) = arg.replace("ftp=","",1).split(":")
+ except:
+ (host, port) = ("", 0)
+ #print "ftp: %s:%s" % (host, port)
+ values["Ftp"] = host
+ values["FtpPort"] = dbus.UInt16(port)
+ if arg.startswith("socks="):
+ try:
+ (host, port) = arg.replace("socks=","",1).split(":")
+ except:
+ (host, port) = ("", 0)
+ #print "socks: %s:%s" % (host, port)
+ values["Socks"] = host
+ values["SocksPort"] = dbus.UInt16(port)
+ if arg.startswith("rtsp="):
+ try:
+ (host, port) = arg.replace("rtsp=","",1).split(":")
+ except:
+ (host, port) = ("", 0)
+ #print "rtsp: %s:%s" % (host, port)
+ values["Rtsp"] = host
+ values["RtspPort"] = dbus.UInt16(port)
+ if arg.startswith("ignore="):
+ try:
+ ignore_hosts = arg.replace("ignore=","",1).split(",")
+ except:
+ ignore_hosts = []
+ #print "ignore: %s" % ignore_hosts
+ values["Ignore"] = ignore_hosts
+
+print values
+
+service.SetProperty("Proxy.Configuration", dbus.Dictionary(values,
signature='sv'))
+
--
1.7.1
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman