~ubuntu-branches/ubuntu/maverick/ubuntu-system-service/maverick

« back to all changes in this revision

Viewing changes to test/test_no_proxy

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2008-08-19 14:18:18 UTC
  • Revision ID: james.westby@ubuntu.com-20080819141818-6gs3fa82dxidv52p
Tags: 0.1.6
* debian/control:
  - add missing depends on policykit and python-dbus
* add socks support
* support no_proxy environment

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import dbus
 
4
import os
 
5
 
 
6
priv = "com.ubuntu.systemservice.setnoproxy"
 
7
 
 
8
session_bus = dbus.SessionBus()
 
9
system_bus = dbus.SystemBus()
 
10
 
 
11
ser = dbus.Interface(system_bus.get_object("com.ubuntu.SystemService","/"),
 
12
                     "com.ubuntu.SystemService")
 
13
 
 
14
try:
 
15
    ser.set_no_proxy("host1,host2")
 
16
except dbus.DBusException, e:
 
17
    print e
 
18
    obj = session_bus.get_object('org.freedesktop.PolicyKit.AuthenticationAgent', '/', False)
 
19
    auth = dbus.Interface(obj, "org.freedesktop.PolicyKit.AuthenticationAgent")
 
20
    res = auth.ObtainAuthorization(priv,
 
21
                                   dbus.UInt32(0),
 
22
                                   dbus.UInt32(os.getpid()), 
 
23
                                   timeout=300)
 
24
    print res
 
25
    if res:
 
26
        print "setting no_proxy"
 
27
        res=ser.set_no_proxy("host1,host2")
 
28
        print res
 
29
    else:
 
30
        print "authentication failure"