MINI MINI MANI MO

Path : /usr/lib/python2.7/site-packages/slip/dbus/
File Upload :
Current File : //usr/lib/python2.7/site-packages/slip/dbus/polkit.pyc


iZc@sdZddlZddlmZddlmZddddd	d
gZdZdZdefd
YZ	de	dddZdejfdYZ
defdYZeZdZeidZdS(smThis module contains convenience decorators and functions for using
PolicyKit with dbus services and clients.iN(t	decorator(tmethod_call_no_timeouttrequire_authtenable_proxytAUTHFAIL_DONTCATCHtNotAuthorizedExceptiontAreAuthorizationsObtainabletIsSystemBusNameAuthorizedAsynccsfd}|S(sDecorator for DBus service methods.

    Specify that a user needs a specific PolicyKit authorization `polkit_auth´
    to execute it.cs)t|dstt|d|S(Nt_dbus_is_methodt_slip_polkit_auth_required(thasattrtAssertionErrortsetattr(tmethod(tpolkit_auth(s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pytrequire_auth_decorator)s((RR((Rs4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyR#ssBorg.fedoraproject.slip.dbus.service.PolKit.NotAuthorizedException.cBseZRS((t__name__t
__module__(((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyR4scs|dkst|stdtfksBdksBtdks`ts`tdksttstfd|dk	rt|Sfd}|SdS(sDecorator for DBus proxy methods.

    Let's you (optionally) specify either a result value or an exception type
    and a callback which is returned, thrown or called respectively if a
    PolicyKit authorization doesn't exist or can't be obtained in the DBus
    mechanism, i.e. an appropriate DBus exception is thrown.

    An exception constructor may and a callback must accept an `action_id´
    parameter which will be set to the id of the PolicyKit action for which
    authorization could not be obtained.

    Examples:

    1) Return `False´ in the event of an authorization problem, and call
    `error_handler´:

        def error_handler(action_id=None):
            print "Authorization problem:", action_id

        class MyProxy(object):
            @polkit.enable_proxy(authfail_result=False,
                                 authfail_callback=error_handler)
            def some_method(self, ...):
                ...

    2) Throw a `MyAuthError´ instance in the event of an authorization problem:

        class MyAuthError(Exception):
            def __init__(self, *args, **kwargs):
                action_id = kwargs.pop("action_id")
                super(MyAuthError, self).__init__(*args, **kwargs)
                self.action_id = action_id

        class MyProxy(object):
            @polkit.enable_proxy(authfail_exception=MyAuthError)
            def some_method(self, ...):
                ...csy|||SWntjk
r}|j}|jtsGn|tt}dk	rsd|ndk	ryd|}Wn}nX|ntkrnSXdS(Nt	action_id(tdbust
DBusExceptiont
get_dbus_namet
startswithtAUTH_EXC_PREFIXtlentNoneR(tfunctptktetexc_nameRtaf_exc(tauthfail_callbacktauthfail_exceptiontauthfail_result(s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyt
_enable_proxyds$
	cs
t|S(N(R(R(R#(s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pytdecoratesN(RtcallableRRt
issubclasst	ExceptionR(RR"R!R R$((R#R R!R"s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyR7s'$!
cBseZdZdZdZRS(sqException which a DBus service method throws if an authorization
    required for executing it can't be obtained.sAorg.fedoraproject.slip.dbus.service.PolKit.NotAuthorizedExceptioncOs4|jjd||_tt|j||dS(Nt.(t	__class__t_dbus_error_nametsuperRt__init__(tselfRRR((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyR,s(RRt__doc__R*R,(((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyRstPolKitcBseZdZdZdZdZd
Zd
Zd
Z	d
Z
edZe
dZe
dZe
dZe
dZd	Zd
ZdZeidZRS(s"Convenience wrapper around polkit.sorg.freedesktop.PolicyKit1s%/org/freedesktop/PolicyKit1/Authoritys$org.freedesktop.PolicyKit1.AuthoritycCsM||jkrItjrItjjtjdt_dt_dt_ndS(N(t
_dbus_nameR/t_PolKit__bustremove_signal_receivert_PolKit__signal_receiverRt_PolKit__interface(tclstnamet	old_ownert	new_owner((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyt_on_name_owner_changeds
		cCsItjsBtjt_tjjd|jddddt_ntjS(Nthandler_functiontsignal_nametNameOwnerChangedtdbus_interfacesorg.freedesktop.DBus(R/R1Rt	SystemBustadd_signal_receiverR9R3(R-((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyt_buss		cCs%tjs|jjt_ntjS(N(R/t_PolKit__bus_nameR@tget_unique_name(R-((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyt	_bus_names	cCs[tjsTy1tj|jj|j|j|jt_WqTtj	k
rPqTXntjS(N(
R/R4Rt	InterfaceR@t
get_objectR0t
_dbus_patht_dbus_interfaceR(R-((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyt
_interfaces	cCs
t|jS(N(tboolRH(R-((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyt_polkit_presentscCsN|jjdd}tj|d}y|j|}Wn
d}nX|S(Nsorg.freedesktop.DBuss/org/freedesktop/DBus(R@RERRDtGetConnectionUnixUserR(R-tsystem_bus_namet
bus_objectt
bus_interfacetuid((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyt__dbus_system_bus_name_uids	
cCsN|js
tS|jjdi|jd6f|idd\}}}|pM|S(Nssystem-bus-nameR6it(RJtTrueRHtCheckAuthorizationRC(R-t
authorizationt
is_authorizedtis_challengetdetails((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyt__authorization_is_obtainables		csGjs
tSt|tr(|g}ntfd|t}|S(Ncs|oj|S(N(t$_PolKit__authorization_is_obtainable(txty(R-(s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyt<lambda>s(RJRRt
isinstancet
basestringtreduce(R-tauthorizationst
obtainable((R-s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyRs	c	
s|js.|dkp*|j|dkSd}|rG|dO}nfd}|jjdi|d6f|||dd|d|d	tdS(
Niics|\}}}|dS(N((targsRURVRW(t
reply_handler(s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pytreply_cbsssystem-bus-nameR6RQRct
error_handlerttimeout(RJRt!_PolKit__dbus_system_bus_name_uidRHRSR(	R-RLRRcRet	challengeRWtflagsRd((Rcs4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyRs	

N(RRR.R0RFRGRR4R1RAR3tclassmethodR9tpropertyR@RCRHRJRgRYRRRR(((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyR/s"
	
		cCs
tj|S(N(t__polkitR(R`((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyRscCstj||||||S(N(RlR(RLRRcReRhRW((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyR
s(R.RRt	constantsRt__all__RRtobjectRRRRRR/RlRRRR(((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyt<module>s			On		

OHA YOOOO