%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/share/system-config-printer/__pycache__/
Upload File :
Create Path :
Current File : //usr/share/system-config-printer/__pycache__/asyncipp.cpython-312.pyc

�

Hf�h���ddlZddlZddlZddlmZddlmZddlmZddlmZddlZejd�ddl
Z
ddl�ddlZddlZejejej��Gd	�d
ej �ZGd�d�ZGd
�d�ZGd�de�Zedk(r+ed�Gd�d�Ze�ej0�yy)�N)�GObject)�GLib)�Gdk)�Gtkz1.9.60)�*)�domain�	localedirc�F�eZdZ			d
d�Zd�Zd�Zd�Zd�Zdd�Zd�Z	d	�Z
y)�_IPPConnectionThreadNc
�@�tjj|�|jd�||_||_||_||_|	|_||_	||_
||_tjd�|_||_d|_t#d|z�y)NT�F�+%s)�	threading�Thread�__init__�	setDaemon�_queue�_conn�host�port�_encryption�_reply_handler�_error_handler�
_auth_handler�queue�Queue�_auth_queue�user�
_destroyed�
debugprint)
�self�myqueue�conn�
reply_handler�
error_handler�auth_handlerrrr�
encryptions
          �,/usr/share/system-config-printer/asyncipp.pyrz_IPPConnectionThread.__init__0s���	���!�!�4�(�����������
���	���	�%���+���+���)��� �;�;�q�>�����	�����E�D�L�!�c�4�tjd|z�y�Nz-%s��debugr �r!s r(�__del__z_IPPConnectionThread.__del__C���
���%�$�,�'r)c�:�|jj|�y�N)r�put�r!�passwords  r(�
set_auth_infoz"_IPPConnectionThread.set_auth_infoFs�������h�'r)c��|j�tj�|_|j�tj�|_|j
�tj�|_|jr tj|j�ntj�|_tj|j�	tj|j|j|j
��}|jd�	t!d�|j"j%�|_|j"j)�}t!dt+|�z�|�|j"j-��n�|j.r|j"j-���d|_|\}}}}}}	|dk7r||_|dk7r||_|	dk7r|	|_|dk(r�|d|_tj|j�t!d|jz�tj|j�	tj|j|j|j
��}t!d�|j"j-�|jd����	t!d
|z�||g|��i|��}
|tjj6j8k(r)|
ik(r$tj:tj<d��t!d�|j|
�|j"j-���Kt!d�|` |`|`|`|`|`!~tjd�y#t$r}d}|j|�Yd}~���d}~wwxYw#t$rA}t!d	�|j"j-�|j|�Yd}~��Bd}~wwxYw#t>$r2}t!d
t+|�z�|j|�Yd}~��d}~wwxYw)N)rrr'TzAwaiting further instructionsz
Next task: %sFrzSet user=%s; reconnecting...z...reconnectedz	...failedzCall %s�z
...successz...failure (%s)zThread exiting)"r�cups�	getServerr�getPortr�
getEncryptionr�setUser�getUser�setPasswordCB2�_auth�
Connection�_reply�RuntimeError�_errorr r�empty�idle�get�repr�	task_donerrrr�adminGetServerSettings�__call__�IPPError�IPP_NOT_AUTHORIZED�	Exceptionrr)r!r#�e�item�fn�args�kwds�rh�eh�ah�results           r(�runz_IPPConnectionThread.runIse���9�9�����)�D�I��9�9������D�I����#�#�1�1�4�D���9�9��L�L�$�)�)�$�����D�I����T�Z�Z�(�	��?�?����)-���/3�/?�/?�A�D�
�K�K���
��7�8����)�)�,�D�I��;�;�?�?�%�D���$��+�5�6��|����%�%�(��������%�%�(���D�I�+/�(�R��t�R��R��U�{�&(��#��U�{�&(��#��U�{�%'��"��T�z� ��G��	����d�i�i�(��:�T�Y�Y�F�G��#�#�T�Z�Z�0�$��?�?����15���7;�7G�7G�I�D�� 0�1��K�K�)�)�,��K�K��&��

 ��I��N�+��T�1�D�1�D�1������?�?�H�H�H���|�"�m�m�T�-D�-D�b�I�I��L�)����V�$�

�K�K�!�!�$�}�@	�$�%��J��������K�������T�"��[�	��D��K�K��O�O��	��V$�$���,��K�K�)�)�,��K�K��O�O��$��&�
 ��-��a��8�9����Q����
 �sK�AN�A,O�BP
�	N=�N8�8N=�	P
�	6P�P
�
	Q�(Q�Qc�H�d|_|jjd�y)NT)rrr3r.s r(�stopz_IPPConnectionThread.stop�s�����������r)c����������fd�}�j�ytj||��jj	�}|S)Nc����tj����j|�j�n�j|�j���tj�y�NF)r�
threads_enterrr�
threads_leave)�promptr#�method�resourcer!s ����r(�prompt_authz/_IPPConnectionThread._auth.<locals>.prompt_auth�sO������ ��|��"�"�F�D�J�J�7��"�"�F�D�J�J���I���� �r)r8)rr�idle_addrrG)r!r`r#rarbrcr5s` ```  r(r@z_IPPConnectionThread._auth�s@���	����%���
�
�{�F�+��#�#�'�'�*���r)c����fd�}�js/�jr"tj|�j|�yyy)Nc����js;tj�|�j|�tj�yr]�rrr^rr_)�handlerrWr!s  �r(�
send_replyz/_IPPConnectionThread._reply.<locals>.send_reply�s3����?�?��!�!�$�����V�,��!�!�$�r))rrrrd)r!rWris`  r(rBz_IPPConnectionThread._reply�s6���	����4�#6�#6��M�M�:�t�':�':�F�C�$7�r)c����fd�}�jsG�jr:td�jz�tj|�j|�yyy)Nc����js;tj�|�j|�tj�yr]rg)rh�excr!s  �r(�
send_errorz/_IPPConnectionThread._error.<locals>.send_error�s3����?�?��!�!�$�����S�)��!�!�$�r)zAdd %s to idle)rrr rrd)r!rlrms`  r(rDz_IPPConnectionThread._error�sJ���	����4�#6�#6��(�4�+>�+>�>�?��M�M�:�t�':�':�C�@�$7�r))NNNNNNN)NNN)�__name__�
__module__�__qualname__rr/r6rXrZr@rBrD�r)r(rr/s7��IM�@D�!�"�&(�(�a#�F��$	D�
Ar)rc�J�eZdZdZ			dd�Zd�Zd�Zd�Zd�Zdd�Z	d	�Z
d
�Zy)
�
IPPConnectiona�
    This class starts a new thread to handle IPP operations.

    Each IPP operation method takes optional reply_handler,
    error_handler and auth_handler parameters.

    If an operation requires a password to proceed, the auth_handler
    function will be called.  The operation will continue once
    set_auth_info (in this class) is called.

    Once the operation has finished either reply_handler or
    error_handler will be called.
    Nc	�B�td�||_tj�|_t	|j||||||||��	|_|j
j
�ttjj�}	g}
ttj�D]a}|ddk(r�ttj|�}t|�|	k7r�5t|||j|��|
j|��c|
|_td|z�y)NzNew IPPConnection�r$r%r&rrrr'r� r)r �_parentrrr�thread�start�typer9rA�getPrinters�dir�getattr�setattr�
_make_binding�append�bindings)
r!r$r%r&rrrr'�parent�
methodtyper��fnamerQs
             r(rzIPPConnection.__init__�s���	�'�(�����[�[�^��
�*�D�J�J��:G�:G�9E�15�D�t�7A�C���	
�������4�?�?�6�6�7�
����$�/�/�*�	$�E��Q�x�3����$�/�/�5�1�B��R�y�J�&���T�5�$�"4�"4�b�"9�:��O�O�U�#�	$�!��
��E�D�L�!r)c�4�tjd|z�yr+r,r.s r(r/zIPPConnection.__del__r0r)c��td|z�|jD]}t||��|jj	�rFtd�|jj�t
jd|j�yy)NzDESTROY: %szStopping worker threadr
)	r r��delattrrx�is_aliverZr�timeout_add_seconds�_reap_thread)r!�bindings  r(�destroyzIPPConnection.destroysr���M�D�(�)��}�}�	$�G��T�7�#�	$��;�;���"��0�1��K�K�����$�$�a��):�):�;�#r)c��|jjr|jj�yt	d|jz�y)NFz Thread %s still processing tasksT)rxrFr�joinr r.s r(r�zIPPConnection._reap_threads5���;�;����J�J�O�O����6����D�E�r)c�:�|jj|�y)z*Call this from your auth_handler function.N)rxr6r4s  r(r6zIPPConnection.set_auth_infos�����!�!�8�,r)c�^�td�|jjd|fi||df�y)NzReconnect...TF)r rr3)r!rr$r%s    r(�	reconnectzIPPConnection.reconnect!s.���N�#��
�
�����w��&�
�u�>�	?r)c������fd�S)Nc�0���j�g|��i|��Sr2)�_call_function)rRrSrQr!s  ��r(�<lambda>z-IPPConnection._make_binding.<locals>.<lambda>'s���%8�T�%8�%8�"�%L�t�%L�t�%L�r)rq)r!rQs``r(rzIPPConnection._make_binding&s	���L�Lr)c��dx}x}}d|vr|d}|d=d|vr|d}|d=d|vr|d}|d=|jj||||||f�y�NFr$r%r&)rr3)r!rQrRrSr$r%r&s       r(r�zIPPConnection._call_function)s���7<�<�
�<�
���d�"� ��1�M��_�%��d�"� ��1�M��_�%��T�!���/�L��^�$��
�
����T�4�&�
�|�E�	Fr))NNNNNNNN�NN)rnrorp�__doc__rr/r�r�r6r�rr�rqr)r(rsrs�s<���;?�@D�*.�"�8(�<��-�?�
M�
Fr)rsc�T�eZdZ	d
d�Zd�Zd�Zd�Zdd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
y)�_IPPAuthOperationNc��d|_d|_d|_d|_d|_d|_||_||_|jj|_	||_
||_||_||_
||_td|z�y)NFr8r)�_auth_called�
_dialog_shown�
_use_password�_cancel�
_reconnect�_reconnected�_userr�try_as_root�_try_as_root�
_client_fn�_client_args�_client_kwds�_client_reply_handler�_client_error_handlerr )r!r$r%r#rrQrRrSs        r(rz_IPPAuthOperation.__init__As���!���"������������!�����
���
� �J�J�2�2������ ��� ���%2��"�%2��"��E�D�L�!r)c�4�tjd|z�yr+r,r.s r(r/z_IPPAuthOperation.__del__Tr0r)c��|`|`|`|`|`|`yr2)rr�r�r�r�r�r.s r(�_destroyz_IPPAuthOperation._destroyWs$���J��O������&��&r)c��|j�td�|j||�S|jrtd|z�|j	|�S|j
r\d|_d|_t|�d|j�d��|j|j|j|j��yd}t|�tjk(r�|j\}}|tjk(s&|tjk(s|tj k(r|tjk(}n�|tj"k(r|j||�S|j	|�St|�tj$k(rY|j\}|tj&k(s|tj(k(r|tj(k(}n"|j	|�S|j	|�S|rtd|z�ntd	|z�|j*r||jd
k7rm|j,j.j0ddk(s|rEtd
�d
|_|j|j|j|j��y|j2s|j	|�S|j.j0}|j.j4}t6j8j;||��d|_t|�d|j�d��|j|j|j|j��y)NzConnection/reconnection failedz,%s (_error_handler): canceled so chaining upFTz$ (_error_handler): reconnecting (as �)...�r$r%z%s (_error_handler): forbiddenz#%s (_error_handler): not authorized�rootr�/zAuthentication: Try as root�rrr8)r�r �_reconnect_errorr�rDr�r�r�r��_reconnect_replyrzr9rLrRrM�
IPP_FORBIDDEN�IPP_AUTHENTICATION_CANCELED�IPP_SERVICE_UNAVAILABLE�	HTTPError�HTTP_UNAUTHORIZED�HTTP_FORBIDDENr�rrxrr�r�authconn�global_authinfocache�remove_auth_infor�)	r!r#rl�	forbiddenrO�m�srrs	         r(r%z_IPPAuthOperation.error_handler_s����?�?�"�
�8�9��(�(�$��4�4��<�<��F��M�N��;�;��$�$��?�?�#�D�O� $�D����t�z�z�+�
,��N�N�D�J�J�*.�*?�*?�*.�*?�*?�
�
A�
��	���:����&��X�X�F�Q���T�,�,�,��T�'�'�'��T�5�5�5��$�"4�"4�4�	��d�2�2�2��,�,�d�C�8�8��{�{�C�(�(�
�3�Z�4�>�>�
)��8�8�D�Q��T�+�+�+��T�(�(�(��$�"5�"5�5�	��{�{�C�(�(��;�;��$�$���8�4�?�@��=��D�E�����J�J�&� �
�Z�Z�
�
�
#�
#�A�
&�#�
-��
�5�6��D�J��N�N�D�J�J�*.�*?�*?�*.�*?�*?�
�
A�
�� � ��;�;��$�$��{�{�����{�{�����%�%�6�6�T�=A�	7�	C������4�:�:�'�	(�����
�
�&*�&;�&;�&*�&;�&;�	�	=r)c
��|jdk(r�|j�tj�|_|jr�|jj
}|jj}tjj||��}|ry|d|jk(r|d|_
d|_~nT|jj
}|jj}tjj||��d|_
d|_|jr.td�d|_|j|j�yd|_|js|j|j�y|j r�t#j$|j&j(ddt"j*j,t"j.j0t3d��	�}|j5t3d
��|j7�|j9�d}	|j:r|j:j=�}	|	�!tj>|j(��}n/t3d�|	z}
tj>|
|j(�
�}|jAd�|j�tj�|_|jddg�|jCd�|jEd�|jG�|jId|jJ�d|_y)NFr�rr
Tr8z%Supplying password after reconnectionzNot authorized�r��modal�destroy_with_parent�message_type�buttons�textzThe password may be incorrect.)r�zAuthentication (%s))�titler��username�response)&r�r�r9r>rxrrr�r��lookup_auth_infor�r�r�r r6�prompt_allowedr�r�
MessageDialogrr��MessageType�ERROR�ButtonsType�CLOSE�_�format_secondary_textrXr��semantic�current_operation�
AuthDialog�
set_prompt�field_grab_focus�set_keep_above�show_all�connect�_on_auth_dialog_response)r!r`r#rarbrr�creds�d�opr�s           r(r&z_IPPAuthOperation.auth_handler�s�������%��z�z�!�!�\�\�^��
��z�z��{�{�'�'���{�{�'�'�� �5�5�F�F�T�MQ�G�S����Q�x�4�:�:�-�-2�1�X��*�,0��)���;�;�#�#�D��;�;�#�#�D��)�)�:�:��AE�
;�
G�!#�D�� �������?�@� %�D������ 2� 2�3��!����"�"����� 2� 2�3������!�!�$�*�*�*;�*;�)-�4�03���0E�0E�+.�?�?�+@�+@�()�*:�(;�	=�A�

�#�#�Q�'G�%H�I�
�E�E�H�
�I�I�L�
���=�=����0�0�3�B�
�:��#�#�D�K�K�8�A��+�,�r�1�E��#�#�5�,0�K�K�9�A�	
���b���:�:������D�J�	���"�b��"�	���J�'�	���$��	�
�
�
�	�	�	�:�t�<�<�=�!��r)c���d|_|jjj|j|j
|j|j|j|jf�yr])
r�rrr3r�r�r�r�r%r&r.s r(�submit_taskz_IPPAuthOperation.submit_task�s[��!����
�
�����t����0A�0A�#�0�0�#�9�9� $�1�1�#�0�0�
2�	3r)c���|j�\}}|dk(r|j}tjj	||f|j
jj|j
jj��||_	|j�|tjjk(s|tjjk(r�d|_|j
j!d�tjj#|j
jj|j
jj��t%d�y||jk(r.||_|j
j!|�t%d�y||_||_d|_|j
j!d�t%d|jz�y)Nr8r�Tz
Auth canceledzPassword supplied.zWill try as %s)�
get_auth_infor�r�r��cache_auth_inforrxrr�_dialog�hider�ResponseType�CANCEL�DELETE_EVENTr�r6r�r r�r�)r!�dialogr�rr5s     r(r�z*_IPPAuthOperation._on_auth_dialog_response�sy��!�/�/�2���x��2�:��:�:�D��%�%�5�5��8@�8B�<@�J�J�<M�<M�<R�<R�<@�J�J�<M�<M�<R�<R�	6�	T����������(�(�/�/�/���(�(�5�5�5��D�L��J�J�$�$�b�)��)�)�:�:����AR�AR�AW�AW�AE���AR�AR�AW�AW�
;�
Y���(���4�:�:��!)�D���J�J�$�$�h�/��,�-����
�%�������
�
� � �"�%��$�t�z�z�1�2r)c�n�td|jz�|j�|j�yy)NzConnected as %s)r r�r�r��r!r#rWs   r(r�z"_IPPAuthOperation._reconnect_replys1��	�%��
�
�2�3��?�?�&�����'r)c�<�td|jz�|jjs|j	|�yd}|j
r|j
j
�}|�td�}ntd�|z}tj|jjddtjjtjj|��}|j�t!|�t"k(rd}n7t!|�t$j&k(r|j(d}nt+|�}|j-td|z��|j/tj0tj2j4td	�tj2j6�|j9tj2j6�|j;d
|j<�t|�d|�d|�d
��|j?�y)NzFailed to connect as %szCUPS server errorzCUPS server error (%s)Tr�z!service-error-service-unavailabler
z3There was an error during the CUPS operation: '%s'.�Retryr�z. (_reconnect_error): presenting error dialog (z; �)) r r�rr�rDr�r�r�rr�r�r�r�r��NONEr�rzrCr9rLrRrHr��add_buttons�STOCK_CANCELr�r��OK�set_default_responser��_on_retry_server_error_response�show)r!r#rlr��msgr��messages       r(r�z"_IPPAuthOperation._reconnect_error%s����-��
�
�:�;��z�z�(�(��K�K����
���=�=����0�0�3�B�
�:��'�(�C��,�-��2�C����d�j�j�&7�&7�%)�t�,/�O�O�,A�,A�'*���';�';�$'�	
)���?�?�"�t�S�z�\�'A�9�G�
�3�Z�4�=�=�
(��h�h�q�k�G��C�j�G�	����$;�=D�$E�"F�	G�	�
�
�s�'�'��)9�)9�)@�)@���z�3�#3�#3�#6�#6�	8�	���� 0� 0� 3� 3�4�	�	�	�:�t�C�C�D���3��)�	*�	���	r)c���|j�|tjjk(r�t	|�d|j
jj�d��|j
j|j
jj|j|j��yt	d|z�|jtjdtd���y)Nz': got retry response, reconnecting (as r�r�z%s: got cancel responserzOperation canceled)r�rr�r�r rrxrr�r�r�rDr9rLr�)r!r�r�s   r(r�z1_IPPAuthOperation._on_retry_server_error_responseLs��������s�'�'�*�*�*���t�z�z�0�0�5�5�7�
8��J�J� � �$�*�*�"3�"3�"8�"8�04�0E�0E�04�0E�0E�
!�
G�
�1�D�8�9��K�K�����1�-A�+B�C�Dr)c��t|�dt|����|jrGt|�d|j���|j|j|�|j	�ytd|z�y)Nz (_error): handling z (_error): calling z(%s (_error): no client error handler set)r rHr�rr�)r!rls  r(rDz_IPPAuthOperation._errorXs`���$��c�
�C�D��%�%���t�9�9�;�
<��&�&��
�
�C�8��M�M���B�T�I�Jr))NNNNr�)rnrorprr/r�r%r&r�r�r�r�r�rDrqr)r(r�r�@sC��6:�"�&(�'�Q=�f?"�B3�3�@ �%�N
E�Kr)r�c�(�eZdZ				dd�Zd�Zd�Zy)�IPPAuthConnectionNc
�"�||_|	|_||_|
|_d}tj
j
||��}|r|ddk7s|r|d}~t|||�}
tj|||
j|
j||||��y)Nr�rr�ru)r�r�r�r�r�r�r�r�rsrr%r&)r!r$r%r&rrr'r�r�r�r�rr�r�s              r(rzIPPAuthConnection.__init__fs������,���&��� ��
����-�-�>�>�T�EI�?�K����Q�x�6�!�[��Q�x����
�}�d�
C������M�.0�.>�.>�-/�_�_�4�%)���	�	Mr)c�<�d|_tj|�yr2)r�rsr�r.s r(r�zIPPAuthConnection.destroy~s����
����t�$r)c	���dx}x}}d|vr|d}|d=d|vr|d}|d=d|vr|d}|d=t||||jj|||�}|j�yr�)r�rxrr�)r!rQrRrSr$r%r&r�s        r(r�z IPPAuthConnection._call_function�s���7<�<�
�<�
���d�"� ��1�M��_�%��d�"� ��1�M��_�%��T�!���/�L��^�$��
�}�d� $��� 0� 0�"�d�D�B��	���r))
NNNNNNNTTN)rnrorprr�r�rqr)r(r�r�es��:>�FJ�@D��M�0%�r)r��__main__Tc�<�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
y	)
�UIc��tj�}|jd|j�tjjd�}|jd|j�tj�}|j|ddd�|j|�tjjd�|_
|jjd|j�|jjd�|j|jddd�d|_
|j�y)Nr��Connect�clickedFrzGet Devices)r�Windowr�r��Button�new_with_label�connect_clicked�VBox�
pack_start�add�get_devices_button�get_devices�
set_sensitiver#r�)r!�w�b�vboxs    r(rzUI.__init__�s����
�
�
�A�
�I�I�y�$�,�,�/��
�
�)�)�9�5�A�
�I�I�y�$�"6�"6�7��8�8�;�D��O�O�Q��u�a�0�
�E�E�4�L�&)�j�j�&?�&?��&O�D�#��#�#�+�+�Y��8H�8H�I��#�#�1�1�5�9��O�O�T�4�4�e�U�A�F��D�I�
�J�J�Mr)c��	|jj�tj�y#t$rY� wxYwr2)r#r��AttributeErrorr�	main_quit)r!�windows  r(r�z
UI.destroy�s7��
��	�	�!�!�$�
�M�M���"�
��
�s�1�	=�=c��|jr|jj�t|j|j��|_y)Nr�)r#r�r��	connected�connect_failed�r!�buttons  r(r
zUI.connect_clicked�s5���y�y��	�	�!�!�$�)����9=�9L�9L�N�D�Ir)c�h�tdt|�z�|jjd�y)NzSuccess: %sT)r rHrrr�s   r(rzUI.connected�s'���
��f�
�5�6��#�#�1�1�4�8r)c��tdt|�z�|jjd�|jj�y)NzExc %sF)r rHrrr#r��r!r#rls   r(rzUI.connect_failed�s7����4��:�-�.��#�#�1�1�5�9��I�I��� r)c��|jd�td�|jj|j|j
��y)NFzGetting devicesr�)rr r#�
getDevices�get_devices_reply�get_devices_errorrs  r(rzUI.get_devices�sB��� � �%�(��)�*��I�I� � ��0F�0F�04�0F�0F�
!�
Hr)c��||jk7rtd�ytdt|�z�|jj	d�y)NzIgnoring stale replyzGot devices: %sT�r#r rHrrr�s   r(r"zUI.get_devices_reply�s@���t�y�y� ��2�3���)�D�&�M�9�:��#�#�1�1�4�8r)c��||jk7rtd�ytdt|�z�|jj	d�y)NzIgnoring stale errorzError getting devices: %sTr%rs   r(r#zUI.get_devices_error�s@���t�y�y� ��2�3���3�d�C�j�@�A��#�#�1�1�4�8r)N)rnrorprr�r
rrrr"r#rqr)r(rr�s,��
	�	�	N�	9�	!�
	H�	9�	9r)r)r�configr9�
gi.repositoryrrrrr�requirer�r-�gettext�install�PACKAGEr	rrrsr�r�rn�
set_debuggingr�mainrqr)r(�<module>r/s���*�
��!���������h����������v�~�~��1A�1A�B�hA�9�+�+�hA�\YF�YF�F`K�`K�J	/�
�/�b�z���4��<9�<9�|�E��C�H�H�K�Er)

Zerion Mini Shell 1.0