@@ -0,0 +1,1341 @@
+import dbus%0Aimport os%0A%0A# highly inspired from this code%0A# https://fedorahosted.org/python-slip/browser/slip/dbus/polkit.py%0A%0Astuff = %7B%220%22: (%22org.freedesktop.PolicyKit%22, %22/%22, %22org.freedesktop.PolicyKit%22),%0A         %221%22: (%22org.freedesktop.PolicyKit1%22, %22/org/freedesktop/PolicyKit1/Authority%22, %22org.freedesktop.PolicyKit1.Authority%22)%7D%0A%0Aauthorization = None%0A%0Abus = dbus.SystemBus()%0Afor (version, info) in stuff.iteritems():%0A    (name, path, interface) = info%0A    try:%0A        interface = dbus.Interface(bus.get_object(name, path), interface)%0A        print %22Got interface %25s%22 %25 interface%0A        authobj = bus.get_object(%22org.freedesktop.PolicyKit.AuthenticationAgent%22, %22/%22)%0A        print %22Got authobj %25s%22 %25 authobj%0A        authorization = dbus.Interface(authobj, %22org.freedesktop.PolicyKit.AuthenticationAgent%22)%0A        print %22Got authorization %25s%22 %25 authorization%0A        # print %22Got interface %25s from version %25s %25s%22 %25 (interface, version, info)%0A    except dbus.DBusException, e:%0A        print %22Well %25s failed%22 %25 (name)%0A%0Aif authorization != None:%0A    action_id = ':org.freedesktop.hal.storage.crypto-setup-fixed'%0A    obtained = authorization.ObtainAuthorization(action_id, dbus.UInt32(0), dbus.UInt32(os.getpid()))%0A    if not obtained:%0A        raise Exception(%22failed to get authorization!%22)%0Aelse:%0A    print %22Could not get authorization object%22%0A

add policykit helpers