File: get-proxy-autoconfig

package info (click to toggle)
connman 1.45-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,056 kB
  • sloc: ansic: 101,490; sh: 4,985; python: 2,256; makefile: 488
file content (37 lines) | stat: -rwxr-xr-x 673 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python

import dbus
import urllib.request, urllib.parse, urllib.error

def get_pac(url):
	conn = urllib.request.urlopen(url, proxies={})
	data = conn.read()
	print(data)
	conn.close()

bus = dbus.SystemBus()

manager = dbus.Interface(bus.get_object('net.connman', '/'),
					'net.connman.Manager')

services = manager.GetServices()

for entry in services:
	path = entry[0]
	properties = entry[1]

	proxy = properties["Proxy"]

	if "Method" in proxy:
		print("[ %s ]" % (path))

		method = proxy["Method"]
		print("Method = %s" % (method))

		if method in ["auto"]:
			url = proxy["URL"]
			print("URL = %s" % (url))
			print()
			get_pac(url)
		else:
			print()