%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3.9/site-packages/cockpit/channels/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3.9/site-packages/cockpit/channels/__pycache__/dbus.cpython-39.opt-1.pyc

a

��h�V�@s�ddlZddlZddlZddlZddlZddlmmZddl	m
Z
ddlmZm
Z
mZddlmZmZe�e�ZGdd�d�Zdd	�ZGd
d�de�ZdS)�N)�systemd_ctypes)�Bus�BusError�
introspection�)�Channel�ChannelErrorc@sFeZdZdd�Zdd�dd�Zdd�Zdd	d
�Zdd�Zdd
d�ZdS)�InterfaceCachecCsi|_t�|_dS�N)�cache�set�old��self�r�9/usr/lib/python3.9/site-packages/cockpit/channels/dbus.py�__init__tszInterfaceCache.__init__N��returncCs|j�|�dSr
)r�update)r�
interfacesrrr�injectxszInterfaceCache.injectc�sD|�||dd�IdH\}t�|�}dd�|�d�D�}|�|�|S)Nz#org.freedesktop.DBus.IntrospectableZ
IntrospectcSsi|]}|jdt�|��qS)�name)ZattribrZparse_interface)�.0�tagrrr�
<dictcomp>��z2InterfaceCache.introspect_path.<locals>.<dictcomp>�	interface)�call_method_async�ETZ
fromstring�findallr)r�bus�destination�object_pathZxml�etrrrr�introspect_path{s�

zInterfaceCache.introspect_pathc�s`z|j|WStyYn0|rT|rTz|�|||�IdHWntyRYn0|j�|�Sr
)r�KeyErrorr%r�get�r�interface_namer!r"r#rrr�
get_interface�szInterfaceCache.get_interfacec�s0||jvrdS|j�|�|�||||�IdHSr
)r
�addr*r(rrr�get_interface_if_new�s
z#InterfaceCache.get_interface_if_newc�sD|�||||�IdH}|dur.td|�d���d�|d|d�S)Nz
Interface z
 is not found��methods�in)r*r&�join)rr)�methodr!r"r#rrrr�
get_signature�szInterfaceCache.get_signature)NNN)NNN)	�__name__�
__module__�__qualname__rrr%r*r,r2rrrrr	ss
r	cCs"dd�|��D�|�|i�|<dS)NcSsi|]\}}||j�qSr)�value)r�k�vrrrr�rz!notify_update.<locals>.<dictcomp>)�items�
setdefault)�notify�pathr)�propsrrr�
notify_update�sr>c@s�eZdZejdd�ZdZdZdZdZ	dZ
dd�Zdd�Zd	d
�Z
dd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)�DBusChannelr)�indentz
dbus-json3Nc
�s�fdd���fdd�}�j|dddd�jd�z$�j�dddd	d
�j�IdH\}Wn�ty�}z�|jdkr�z$�j�ddddd
�jd�IdHWq�ty�}z*t�d�j|j��jdd�WYd}~q�d}~00nt�d�j|j�WYd}~nd}~00�|�dS)Ncs �j|kr|�_�j|d�dS)N��owner)rB�	send_jsonrArrr�
send_owner�s
z9DBusChannel.setup_name_owner_tracking.<locals>.send_ownercs(|��\}}}�|dkr|ndd�dS)Nr-rA)�get_body)�message�_nameZ_old�new)rDrr�handler�sz6DBusChannel.setup_name_owner_tracking.<locals>.handlerzorg.freedesktop.DBusz/org/freedesktop/DBusZNameOwnerChanged)�senderr<r�memberZarg0ZGetNameOwner�sz)org.freedesktop.DBus.Error.NameHasNoOwnerZStartServiceByNameZsurz Failed to start service '%s': %srAz'Failed to get owner of service '%s': %s)	�add_signal_handlerrr!rr�logger�debugrFrC)rrI�unique_name�errorZstart_errorr)rrDr�setup_name_owner_tracking�s8��

�$(z%DBusChannel.setup_name_owner_trackingc
s�t��_|�d��_g�_|�d�}|�d�}z�|dur||durT|dkrTtddd��t�d|�j�tj	|�jdud	��_
n�|d
kr�t�d�j��jjj
�_
n`|dkr�t�d
�j�t���_
n>|dks�|dur�t�d�j�t���_
ntdd|�d�d��Wn@t�yB}z&tdd|�d|��d�|�WYd}~n
d}~00z�j
�dd�Wn6t�y�}z|jtjk�rx�WYd}~n
d}~00t���_�jdu�r�dd��fdd�}��|��n���dS)Nrr!�addressZnonezprotocol-errorz0only one of "bus" and "address" can be specified�rFzget bus with address %s for %s)rSZ
bus_clientZinternalzget internal bus for %sZsessionzget session bus for %s�systemzget system bus for %sz
invalid bus "�"zfailed to connect to z bus: rrc	�sp�j4IdH�H���IdH�jr4�j�jd�n��ddi�Wd�IdHql1IdHsb0YdS)N)rPZproblemz	not-found)�watch_processing_lockrRrB�ready�closerrrr�	get_readys
z&DBusChannel.do_open.<locals>.get_ready)r	rr'r�matchesrrNrOrrHr!ZrouterZinternal_busZclientZdefault_userZdefault_system�OSErrorZattach_event�errnoZEBUSY�asyncio�LockrW�create_taskrX)r�optionsr!rS�exc�errrZrrr�do_open�sB

0
zDBusChannel.do_opencs�tfi|��}d|d<d|vr2�jdur2�j|d<|�d�dkrF|d=��fdd�}�jdurzd|vrz|d�jkrz|}n�}d�d	d
�|��D��}���s�z�j�||�}Wq�Wq�ty�Yq�0q��j	�
|�dS)N�signal�typerJ�path_namespace�/cs$�jdur �j|��kr �|�dSr
)rBZ
get_senderrT�rIrrr�filter_ownersz4DBusChannel.add_signal_handler.<locals>.filter_owner�,css"|]\}}|�d|�d�VqdS)z='�'Nr)r�keyr6rrr�	<genexpr>rz1DBusChannel.add_signal_handler.<locals>.<genexpr>)�dictrr'r0r9Z
is_closingr!�	add_match�InterruptedErrorr[�append)rrI�kwargs�rrj�funcZr_string�matchrrirrM
s$
 zDBusChannel.add_signal_handlercs$��fdd�}�j|fi|��dS)Ncs���|��dSr
)r`rTrirr�sync_handler,sz:DBusChannel.add_async_signal_handler.<locals>.sync_handler)rM)rrIrsrwrrir�add_async_signal_handler+sz$DBusChannel.add_async_signal_handlerc
�sx|d\}}}}|�d�}|�d�}|�d�}|dur@|d9}nd}|�d�}	|	durft|�dkrfd	}	|	du�r\z0t�d
||�|j�|||j|j|�IdH}	Wn�ty�}
z,|j	|
jd|
j
��gg|d�WYd}
~
dSd}
~
0t�y|j	d
d|�d|�d�gg|d�YdSt�yZ}z(|j	dd|��gg|d�WYd}~dSd}~00z�|jj
|j||||	g|�R�}|jj||d�IdH}
|j4IdH�D|j	|
��g||du�r�dnd|
�d�d�Wd�IdH�q�1IdH�s�0YWntt�y<}
z$|j	|
j|
j
gg|d�WYd}
~
n@d}
~
0t�yrt�d|�|j	dt��gg|d�Yn0dS)N�call�id�flags�timeouti�l����rfrr-z%Doing introspection request for %s %szIntrospection: �rQrzz(org.freedesktop.DBus.Error.UnknownMethodzIntrospection data for method � z not availablezpython.error)r|�<T)�replyrzr{rfzdo_call(%s): generic exception)r'�lenrNrOrr2r!rrrCrFr&�	ExceptionZmessage_new_method_callZ
call_asyncrWrE�	exception�	traceback�
format_exc)rrFr<�ifacer1�args�cookier{r|Z	signaturerQrbZmethod_callr�rrr�do_call0sT





"��
�8,zDBusChannel.do_callc�s6|d}t�d|��fdd�}�j|fi|��dS)N�	add-matchzadding match %sc	�spt�d��j4IdH�>�j|��|��|��t|���gd�Wd�IdHql1IdHsb0YdS)Nz	got match)re)	rNrOrWrC�get_pathr*�
get_member�listrErTrrr�	match_hitms

�z+DBusChannel.do_add_match.<locals>.match_hit)rNrOrx)rrFrpr�rrr�do_add_matchis
zDBusChannel.do_add_matchc�s���fdd�}�j||dd��j��j|dd�IdH\}|��D]f\}}|��D]T\}	}
�dusj|	�krR�j�|	�j�j|�IdH}|r�|�|	|i�t|||	|
�qRqBdS)Nc
	�sd|��}|dkr�|��\}}t�d||�i}i}�j4IdH��|��D]T\}}�dusb|�krJ�j�|�j�j	|�IdH}|r�|�
||i�t||||�qJ�j|d��j|d�Wd�IdHq�1IdHs�0Yn||dk�r`|��\}}	t�d||	��j4IdH�2|t
�|	�i}�j|d�Wd�IdH�q`1IdH�sV0YdS)NZInterfacesAddedzinterfaces added %s %s��meta�r;ZInterfacesRemovedzinterfaces removed %s %s)r�rErNrOrWr9rr,r!rrr>rCro�fromkeys)
rFrKr<Zinterface_propsr�r;rr=�mmr�r)rrrrI~s*8
z6DBusChannel.setup_objectmanager_watch.<locals>.handlerz"org.freedesktop.DBus.ObjectManager)r<rZGetManagedObjects)	rxr!rrr9rr,rr>)rr<r)r�r;rIZobjects�pZifacesr�r=r�rr�r�setup_objectmanager_watchys ��z%DBusChannel.setup_objectmanager_watchc	�s��fdd�}�j��j�j|�IdH}|dur@|�|�}||i}|�|�|r`�j|d|d�n�j|d|d�|D]V}	|	�d�r�qtz2�j��j|ddd|	�IdH\}
t	|||	|
�Wqtt
y�Yqt0qtdS)	Nc	�s
�j4IdH��|��}|��\}}}t�d||||�|D]~}z&�j��j|ddd||�IdH\}WnJty�}z2t�d||�j|t	|��WYd}~q<WYd}~n
d}~00|||<q<i}t
||||��j|d�Wd�IdH�q1IdHs�0YdS)NzNOTIFY: %s %s %s %s�org.freedesktop.DBus.PropertiesZGet�ssz+failed to fetch property %s.%s on %s %s: %sr�)rWr�rErNrOr!rrr�strr>rC)	rFr<rr=Zinvalids�invr�rbr;rrrrI�s&��"
z-DBusChannel.setup_path_watch.<locals>.handlerr�)rrg)rr<zorg.freedesktop.DBus.ZGetAllrL)rr%r!rr'rrx�
startswithrr>r)rr<r)Zrecursive_propsr�r;rIZ	this_metarrr=rrr�setup_path_watch�s4

��
�zDBusChannel.setup_path_watchc
�s||d}|�d�}|�d�}|�d�}|�d�}|p6|}||k}|dusP|dur�t�d|�|jddgg|d	�|jg|d
�dSz�|j4IdH�|i}i}	|�|||||	�IdH|r�|�||||	�IdH|j|d�|j|	d�|jg|dd
�Wd�IdH�q&1IdH�s0YWnNt�yv}
z4t�d
||
j�|j|
j	|
jgg|d	�WYd}
~
n
d}
~
00dS)N�watchr<rgrrzz#ignored incomplete watch request %szx.y.zzNot Implementedr})r�rzr�r�z#do_watch(%s) caught D-Bus error: %s)
r'rNrOrCrWr�r�rrFr)rrFr�r<rgr)r��	recursiver�r;rQrrr�do_watch�s2



DzDBusChannel.do_watchc�s|j�|d�dS)Nr�)rr)rrFrrr�do_meta�szDBusChannel.do_metacCs�t�|�}t�d|j|�d|vr4|�|�|��n^d|vrN|�|�|��nDd|vrh|�|�|��n*d|vr�|�|�	|��nt�d|�dSdS)Nzreceive dbus request %s %sryr�r�r�zignored dbus request %s)
�json�loadsrNrOrr`r�r�r�r�)r�datarFrrr�do_data�s
zDBusChannel.do_datacCs&|jD]}|��qg|_|��dSr
)r[�cancelrY)rZslotrrr�do_closes

zDBusChannel.do_close)r3r4r5rZJSONEncoderZjson_encoderZpayloadr[rr!rBrRrdrMrxr�r�r�r�r�r�r�r�rrrrr?�s$(39*0r?)r^r]r�Zloggingr�Zxml.etree.ElementTreeZetreeZElementTreerZcockpit._vendorrZcockpit._vendor.systemd_ctypesrrrZchannelrrZ	getLoggerr3rNr	r>r?rrrr�<module>%s
B2

Zerion Mini Shell 1.0