Debian Codegraph @

src/examples/polkit-raw-dbus.py

raw
1 #!/usr/bin/env python
2
3 # Copyright (C) 2009 Red Hat, Inc.
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2 of the License, or (at your option) any later version.
9 #
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General
16 # Public License along with this library; if not, write to the
17 # Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 # Boston, MA 02111-1307, USA.
19 #
20 # Author: David Zeuthen <[email protected]>
21
22 # Simple example showing how to access the Authority via D-Bus calls
23 #
24
25 import dbus
26
27 bus = dbus.SystemBus()
28 proxy = bus.get_object('org.freedesktop.PolicyKit1', '/org/freedesktop/PolicyKit1/Authority')
29 authority = dbus.Interface(proxy, dbus_interface='org.freedesktop.PolicyKit1.Authority')
30
31 system_bus_name = bus.get_unique_name()
32
33 subject = ('system-bus-name', {'name' : system_bus_name})
34 action_id = 'org.freedesktop.policykit.exec'
35 details = {}
36 flags = 1 # AllowUserInteraction flag
37 cancellation_id = '' # No cancellation id
38
39 result = authority.CheckAuthorization(subject, action_id, details, flags, cancellation_id)
40
41 print result