%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__/cupspk.cpython-312.pyc

�

Hf�m���ddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ed��dZdZdZ
d	ZGd
�d�Zy)�N)�
debugprint)�
DBusGMainLoop)�reduceT)�set_as_defaultz#org.opensuse.CupsPkHelper.Mechanism�/z1org.opensuse.CupsPkHelper.Mechanism.NotPrivilegedc���eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&y%)&�
Connectionc�4�d|_	tj�|_tj�|_tj|||��|_
|j�y#tjj$rdx|_|_Y�[wxYw)N)�host�port�
encryption)�_parent�dbus�
SessionBus�_session_bus�	SystemBus�_system_bus�
exceptions�
DBusException�cupsr	�_connection�_hack_subclass)�selfrrr
s    �*/usr/share/system-config-printer/cupspk.py�__init__zConnection.__init__5s������	8� $��� 1�D��#�~�~�/�D��
 �?�?��04�6@�B���	
��������,�,�	8�37�7�D��� 0�	8�s�2A)�)+B�Bc��t|jj�}t|j�D]T}|ddk(r�t	|j|�}t|�|k7r�1t||�r�>t
|||j��Vy)Nr�_)�typer�getPrinters�dir�getattr�hasattr�setattr�__call__)r�
methodtype�fname�fns    rrzConnection._hack_subclassFs}���$�*�*�6�6�7�
���)�)�*�	2�E��Q�x�3�����)�)�5�1�B��B�x�:�%���4��'���e�R�[�[�1�	2�c��||_y�N)r)r�parents  r�
set_parentzConnection.set_parentTs	����r(c���	|jjtt�}t	j
|t�S#tjj$rYyt$rYywxYwr*)
r�
get_object�CUPS_PK_NAME�CUPS_PK_PATHr�	Interface�
CUPS_PK_IFACErr�AttributeError)r�objects  r�_get_cups_pkzConnection._get_cups_pkXsW��	��%�%�0�0��|�L�F��>�>�&�-�8�8�����,�,�	���	��	�s�=A�A*�A*�)A*c��d}|jdd�}|s$|j�}	|	r	|	j|�}|s|s||i|��Sd}
		||d|i�}
t
|
�tk(r"|
dd}|
ddk(rt|�dk(r|dS|S	|
dk7r"td|�d	t!|
����||i|��Sy#tjj
$rY��wxYw#tjj
$ra}|j�tk(r@td|j�z�tjtjd��Yd}~��d}~wwxYw)
N�	signaturezPolicyKit communication issue�r�zDBus exception: %s�pkcancelzPolicyKit call to z did not work: )�popr5�get_dbus_methodrrrr�tuple�len�
get_dbus_name�CUPS_PK_NEED_AUTHr�get_dbus_messager�IPPError�IPP_NOT_AUTHORIZED�repr)
r�use_fallback�pk_function_name�pk_args�fallback_function�args�kwds�pk_function�dbus_args_signature�cups_pk�	pk_retval�retval�es
             r�_call_with_pk_and_fallbackz%Connection._call_with_pk_and_fallbackdsm����"�h�h�{�D�9����'�'�)�G���")�"9�"9�:J�"K�K��{�$�d�3�d�3�3�3�	��
�'��R�>Q�R�	��	�?�e�+�&�q�r�]�F�!��|�r�)��v�;�!�+�#)�!�9�,�#)�M����?��)�4��+;�=�
>�$�d�3�d�3�3���I���4�4�����6�?�?�0�0�
��?�?�$�(9�9�� 4�q�7I�7I�7L� L�M��-�-��(?�(?��L�L���
�s0�B0�9C�C�0C�C�E�0AE�Ec��dg}t|�t|�k7r!d|d<|j|�t|�Sd}tt|��D�]r}t	||�||k7�rF||t
k(r3t	||�tk(r|jt||���X||t
k(r3t	||�tk(r|jt||����||t
k(r3t	||�tk(r|jt||����||t
k(r||�|jd���||tk(r4t	||�tk(r|jt||����9||tk(r||�|jg���]d}|j||���u||d<t|�S)NFTrr9)r>�extendr=�ranger�str�int�append�float�bool�list)r�typesrIrO�	exception�is      r�_args_to_tuplezConnection._args_to_tuple�s�������u�:��T��"��F�1�I��M�M�%� ���<���	��s�5�z�"�	#�A��D��G�}��a��(���8�s�?�t�D��G�}��';��M�M�#�d�1�g�,�/���1�X��_��d�1�g��%�)?��M�M�#�d�1�g�,�/���1�X��_��d�1�g��$�)>��M�M�#�d�1�g�,�/���1�X��_��a����M�M�"�%���1�X��%�$�t�A�w�-�5�*@��M�M�$�t�A�w�-�0���1�X��%�$�q�'�/��M�M�"�%�� $�I��M�M�$�q�'�"�9	#�<��q�	��V�}�r(c�~�g}|D],}||vr|j||��|jd��.t|�S)Nr9)rWr=)r�namesrJ�ret�names     r�
_kwds_to_varszConnection._kwds_to_vars�sD�����	�D��t�|��
�
�4��:�&��
�
�2��		��S�z�r(c�|�d}d}g}g}d}t|�dk(r.|jttttgg|���\}}}}}n$d|vr|d}d|vr|d}d|vr|d}d|vr|d}||||f}	|j|d||j
jg|��i|��}	t|	j��dkDr1t|	t|	j��d�tk(r|	Si}
|	�T|	j�D]A}t|�tjk(rt|	|�|
t|�<�:|	||
|<�Ci}d}
dt|
�z}|
j�D�cgc]}|j!|�s�|��}}t|�dkDr�d}i}|D]/}|dt|�t|�z
}|dk7r	|
|||<�+|
|}�1|�|||<|
dz
}
dt|
�z}|
j�D�cgc]}|j!|�s�|��}}t|�dkDr��|S#t$r�td	�d|vrd
}t|�dkDrtd�|�}nd}t|�dkDrtd
�|�}nd}|||f}|j|d||j
jg|��i|��}	Y��wxYwcc}wcc}w)NFr��timeout�limit�include_schemes�exclude_schemes�
DevicesGetz-DevicesGet API exception; using old signatureTc��|dz|zS�N�,���x�ys  r�<lambda>z'Connection.getDevices.<locals>.<lambda>����q�3�w��{�r(r9c��|dz|zSrlrnros  rrrz'Connection.getDevices.<locals>.<lambda>rsr(�:z
device-urir8)r>r^rVrUrQr�
getDevices�	TypeErrorrr�keysrrZ�dictr�String�endswith)rrIrJ�
use_pycupsrgrhrirfrG�result�
result_strr]�devices�n�postfixrp�device_keys�
device_uri�device_dict�keys                    rrvzConnection.getDevices�sL���
����������t�9��>�M`�T�M`�M`�be�gj�lo�qt�au�M}�x|�M}�J�Z����'��D� ��y�/���$���W�
�� �D�(�"&�'8�"9�� �D�(�"&�'8�"9���E�?�O�D��	D�4�T�4�4�Z�5A�7�59�5E�5E�5P�5P�D�7;�D�?C�D�F�:����
���"�t�V�D�����4G��4J�-K�'L�PT�'T��]��
����[�[�]�
.����7�d�k�k�)�),�V�A�Y��J�s�1�v�&�$*�1�I�J�q�M�	
.���
����Q��-��",�/�/�"3�K�Q�q�z�z�'�7J�q�K��K��;��!�#��J��K� �
/���.��Q��#�g�,�.�/���,�&�'1�!�}�K��$�!+�A��J�
/��%�&1��
�#�
��F�A��C��G�m�G�&0�o�o�&7�O��1�:�:�g�;N�1�O�K�O�!�;��!�#�$���{�	D��G�H��D� �!�
��O�$�q�(�"(�*B�*9�#;��#%���O�$�q�(�"(�*B�*9�#;��#%���o��?�G�4�T�4�4�Z�5A�7�59�5E�5E�5P�5P�D�7;�D�?C�D�F�'	D��TL��"Ps+�2-H%�(J4�?J4�7J9�J9�%BJ1�0J1c��|jtgg|���\}}|f}|j|d||jjg|��i|��y)N�	JobCancel)r^rVrQr�	cancelJob�rrIrJr|�jobidrGs      rr�zConnection.cancelJob;sa��1�d�1�1�3�%�?�$�?���U��)��'��'�'�
�(3�W�(,�(8�(8�(B�(B�	7�*.�	7�26�	7r(c��|jttgg|���\}}}||f}|j|d||jj
g|��i|��y)N�JobSetHoldUntil)r^rVrUrQr�setJobHoldUntil)rrIrJr|r��job_hold_untilrGs       rr�zConnection.setJobHoldUntilGsh��.A�d�.A�.A�3��*�.T�t�.T�+��U�N��.�+��'��'�'�
�(9�7�(,�(8�(8�(H�(H�	7�*.�	7�26�	7r(c��|jtgg|���\}}|f}|j|d||jjg|��i|��y)N�
JobRestart)r^rVrQr�
restartJobr�s      rr�zConnection.restartJobPsa��1�d�1�1�3�%�?�$�?���U��)��'��'�'�
�(4�g�(,�(8�(8�(C�(C�	7�*.�	7�26�	7r(c��d}d}t|�dk(r"|jttgg|���\}}}nG|jtgg|���\}}d|vr|d}n"d|vr|d}nd|vr|d}n|s
t��d}|�s�|�|���t	j
d��\}}	t
j|�||	f}
|j|d|
|jjg|��i|��t
j|	tj�}t
j|d	�}|jd
�|�vt
j|d
tj �|j#�}|dk7r�t
j$||j'd��|j#�}|dk7r�;n\|jd
�|j#�}|dk7r6|j%|j'd��|j#�}|dk7r�6|j�t
j(|	�y|f}
|j|d|
|jjg|��i|��y)
af Keeping this as an alternative for the code.
            We don't use it because it's not possible to know if the call was a
            PK-one (and so we push the content of a temporary filename to fd or
            file) or a non-PK-one (in which case nothing should be done).

                filename = None
                fd = None
                file = None
                if use_pycups:
                    if len(kwds) != 1:
                        use_pycups = True
                    elif kwds.has_key('filename'):
                        filename = kwds['filename']
                    elif kwds.has_key('fd'):
                        fd = kwds['fd']
                    elif kwds.has_key('file'):
                        file = kwds['file']
                    else:
                        use_pycups = True

                    if fd or file:
        N��filename�fd�filez/tmp)r �FileGet�rtrr9zUTF-8)r>r^rUrw�tempfile�mkstemp�os�closerQr�getFile�open�O_RDONLY�fdopen�seek�lseek�SEEK_SET�readline�write�encode�remove)
rrIrJ�file_objectr�r|�resourcer��tmpfd�tmpfnamerG�tmpfile�lines
             rr�zConnection.getFileYsL��0��
���t�9��>�/B�t�/B�/B�C��:�/U�PT�/U�,�Z��8�%8�T�%8�%8�#��%F��%F�"�Z���T�!��
�+������$�Z���4��"�6�l��!�#�+�%�#�H����;�3J�!)� 0� 0�V� <��U�H��H�H�e����*�G�+�D�+�+�J�,5�w�,0�,<�,<�,D�,D�
;�.2�
;�6:�
;�
�G�G�X�r�{�{�3�E��i�i���-�G��L�L�!���~����"�a����-��'�'�)���b�j��H�H�b�$�+�+�g�"6�7�"�+�+�-�D��b�j�� � �!�$��'�'�)���b�j��%�%�t�{�{�7�';�<�"�+�+�-�D��b�j�
�M�M���I�I�x� ���*�G�+�D�+�+�J�,5�w�,0�,<�,<�,D�,D�
;�.2�
;�6:�
;r(c�6�t|�dk(r"|jttgg|���\}}}nG|jtgg|���\}}d|vr|d}n"d|vr|d}nd|vr|d}n|s
t��d}|�sn���it	j
�\}}	t
j|dtj�|�}t
j|dtj�t
j|d�}
|
dk7r�|
dk7r�t
j||
�t
j|d�}
|
dk7rY|
dk7r�7nRjd�|j�}|dk7r,t
j||�|j�}|dk7r�,t
j|�||	f}|j|d	||jj g|��i|��t
j"|	�y|f}|j|d	||jj g|��i|��y)
Nr�r�r�r�rir9r(�FilePut)r>r^rUrwr�r�r�r�r��readr�r�r�r�rQr�putFiler�)
rrIrJr|r�r�r�r�r�r��bufr�rGs
             rr�zConnection.putFile�s���t�9��>�/B�t�/B�/B�C��:�/U�PT�/U�,�Z��8�%8�T�%8�%8�#��%F��%F�"�Z���T�!��
�+������$�Z���4��"�6�l��!�#�+�%�#�H����;�3J� (� 0� 0� 2��U�H��H�H�e�Q����,��~����"�a����-��g�g�r�3�'���R�i�C�3�J��H�H�e�S�)��'�'�2�s�+�C��R�i�C�3�J�� � �!�$�"�+�+�.���b�j��H�H�e�T�*�&�/�/�2�D��b�j�
�H�H�e����*�G�+�D�+�+�J�,5�w�,0�,<�,<�,D�,D�
;�.2�
;�6:�
;�

�I�I�x� � ��*�G�+�D�+�+�J�,5�w�,0�,<�,<�,D�,D�
;�.2�
;�6:�
;r(c��|jtgg|���\}}|jgd�fi|��\}}}}}	}
d}|sE|sC|
rAtjd��\}}|
j|�t
j|�d}|rO|sM||	|||f}
|j|d|
|jjg|��i|��|rt
j|�yy||	|||f}
|j|d|
|jjg|��i|��y)N)r��ppdname�info�location�device�ppdFT)�text�PrinterAddWithPpdFile�
PrinterAdd)r^rUrcr�r��writeFdr�r�rQr�
addPrinter�unlink)rrIrJr|rbr�r�r�r�r�r��need_unlinkr�rGs              rr�zConnection.addPrinter�s@��0�T�0�0�#��>��>���T�;M�4�;M�;M�OK�<T�OS�<T�8��7�D�(�F�C����x�C�%�-�-�D�9�N�R���K�K��O��H�H�R�L��K��G��V�X�t�X�>�G�+�D�+�+�J�,C�W�,0�,<�,<�,G�,G�
;�.2�
;�6:�
;���	�	�(�#���V�W�d�H�=�G�+�D�+�+�J�,8�'�,0�,<�,<�,G�,G�
;�.2�
;�6:�
;r(c��|jttgg|���\}}}||f}|j|d||jjg|��i|��y)N�PrinterSetDevice)r^rUrQr�setPrinterDevice)rrIrJr|rbr�rGs       rr�zConnection.setPrinterDevice�sg��%8�T�%8�%8�#�s��%K�d�%K�"��T�6���.��'��'�'�
�(:�G�(,�(8�(8�(I�(I�	7�*.�	7�26�	7r(c��|jttgg|���\}}}||f}|j|d||jjg|��i|��y)N�PrinterSetInfo)r^rUrQr�setPrinterInfo)rrIrJr|rbr�rGs       rr�zConnection.setPrinterInfosg��#6�4�#6�#6��S�z�#I�D�#I� ��T�4���,��'��'�'�
�(8�'�(,�(8�(8�(G�(G�	7�*.�	7�26�	7r(c��|jttgg|���\}}}||f}|j|d||jjg|��i|��y)N�PrinterSetLocation)r^rUrQr�setPrinterLocation)rrIrJr|rbr�rGs       rr�zConnection.setPrinterLocationsh��':�t�':�':�C��:�'M��'M�$��T�8���"��'��'�'�
�(<�g�(,�(8�(8�(K�(K�	7�*.�	7�26�	7r(c��|jttgg|���\}}}||f}|j|d||jj
g|��i|��y)N�PrinterSetShared)r^rUrYrQr�setPrinterShared)rrIrJr|rb�sharedrGs       rr�zConnection.setPrinterSharedsg��%8�T�%8�%8�#�t��%L�t�%L�"��T�6���.��'��'�'�
�(:�G�(,�(8�(8�(I�(I�	7�*.�	7�26�	7r(c��|jtttgg|���\}}}}|||f}|j|d||jjg|��i|��y)N�PrinterSetJobSheets)r^rUrQr�setPrinterJobSheets)rrIrJr|rb�start�endrGs        rr�zConnection.setPrinterJobSheets$sn��)<��)<�)<�c�3��_�)T�t�)T�&��T�5�#����$��'��'�'�
�(=�w�(,�(8�(8�(L�(L�	7�*.�	7�26�	7r(c��|jttgg|���\}}}||f}|j|d||jjg|��i|��y)N�PrinterSetErrorPolicy)r^rUrQr�setPrinterErrorPolicy�rrIrJr|rb�policyrGs       rr�z Connection.setPrinterErrorPolicy.sg��%8�T�%8�%8�#�s��%K�d�%K�"��T�6���.��'��'�'�
�(?��(,�(8�(8�(N�(N�	7�*.�	7�26�	7r(c��|jttgg|���\}}}||f}|j|d||jjg|��i|��y)N�PrinterSetOpPolicy)r^rUrQr�setPrinterOpPolicyr�s       rr�zConnection.setPrinterOpPolicy8sg��%8�T�%8�%8�#�s��%K�d�%K�"��T�6���.��'��'�'�
�(<�g�(,�(8�(8�(K�(K�	7�*.�	7�26�	7r(c��|jttgg|���\}}}||f}|j|d||jj
g|��i|��y)N�PrinterSetUsersAllowed)r^rUrZrQr�setPrinterUsersAllowed�rrIrJr|rb�usersrGs       rr�z!Connection.setPrinterUsersAllowedBsg��$7�D�$7�$7��d��$K�d�$K�!��T�5���-��'��'�'�
�(@�'�(,�(8�(8�(O�(O�	7�*.�	7�26�	7r(c��|jttgg|���\}}}||f}|j|d||jj
g|��i|��y)N�PrinterSetUsersDenied)r^rUrZrQr�setPrinterUsersDeniedr�s       rr�z Connection.setPrinterUsersDeniedLsg��$7�D�$7�$7��d��$K�d�$K�!��T�5���-��'��'�'�
�(?��(,�(8�(8�(N�(N�	7�*.�	7�26�	7r(c��|jtttgg|���\}}}}|s|f}n'|jtttgg|���\}}}}|||f}|j|d||jj
g|��i|��y)N�PrinterAddOptionDefault)r^rUrZrQr�addPrinterOptionDefault)	rrIrJr|rb�option�value�valuesrGs	         rr�z"Connection.addPrinterOptionDefaultUs���-@�D�,?�,?��c�3��,W�RV�,W�)��T�6�5���X�F�2E��1D�1D�c�3�PT�EU�1]�X\�1]�.�Z��v�v����(��'��'�'�
�(A�7�(,�(8�(8�(P�(P�	7�*.�	7�26�	7r(c��|jttgg|���\}}}||f}|j|d||jjg|��i|��y)N�PrinterDeleteOptionDefault)r^rUrQr�deletePrinterOptionDefault)rrIrJr|rbr�rGs       rr�z%Connection.deletePrinterOptionDefaultgsg��%8�T�%8�%8�#�s��%K�d�%K�"��T�6���.��'��'�'�
�(D�g�(,�(8�(8�(S�(S�	7�*.�	7�26�	7r(c��|jtgg|���\}}|f}|j|d||jjg|��i|��y)N�
PrinterDelete)r^rUrQr�
deletePrinter�rrIrJr|rbrGs      rr�zConnection.deletePrinterqsa��0�T�0�0�#��>��>���T��'��'��'�'�
�(7��(,�(8�(8�(F�(F�	7�*.�	7�26�	7r(c��|jttgg|���\}}}||f}|j|d||jjg|��i|��y)N�ClassAddPrinter)r^rUrQr�addPrinterToClass�rrIrJr|�printerrbrGs       rr�zConnection.addPrinterToClass|sg��&9�d�&9�&9�3��*�&L�t�&L�#��W�d���/��'��'�'�
�(9�7�(,�(8�(8�(J�(J�	7�*.�	7�26�	7r(c��|jttgg|���\}}}||f}|j|d||jjg|��i|��y)N�ClassDeletePrinter)r^rUrQr�deletePrinterFromClassr�s       rr�z!Connection.deletePrinterFromClass�sg��&9�d�&9�&9�3��*�&L�t�&L�#��W�d���/��'��'�'�
�(<�g�(,�(8�(8�(O�(O�	7�*.�	7�26�	7r(c��|jtgg|���\}}|f}|j|d||jjg|��i|��y)N�ClassDelete)r^rUrQr�deleteClassr�s      rr�zConnection.deleteClass�sa��0�T�0�0�#��>��>���T��'��'��'�'�
�(5�w�(,�(8�(8�(D�(D�	7�*.�	7�26�	7r(c��|jtgg|���\}}|f}|j|d||jjg|��i|��y)N�PrinterSetDefault)r^rUrQr�
setDefaultr�s      rr�zConnection.setDefault�sa��0�T�0�0�#��>��>���T��'��'��'�'�
�(;�W�(,�(8�(8�(C�(C�	7�*.�	7�26�	7r(c��|jtgg|���\}}|df}|j|d||jjg|��i|��y)NT�PrinterSetEnabled)r^rUrQr�
enablePrinterr�s      rr�zConnection.enablePrinter�sc��0�T�0�0�#��>��>���T���,��'��'�'�
�(;�W�(,�(8�(8�(F�(F�	7�*.�	7�26�	7r(c��|jtgg|���\}}|df}|j|d||jjg|��i|��y)NFr�)r^rUrQr�disablePrinterr�s      rrzConnection.disablePrinter�sc��0�T�0�0�#��>��>���T���-��'��'�'�
�(;�W�(,�(8�(8�(G�(G�	7�*.�	7�26�	7r(c��|jtgg|���\}}|ddf}|j|d||jjg|��i|��y)NTr9�PrinterSetAcceptJobs)r^rUrQr�
acceptJobsr�s      rrzConnection.acceptJobs�sf��0�T�0�0�#��>��>���T���r�"��'��'�'�
�(>��(,�(8�(8�(C�(C�	7�*.�	7�26�	7r(c���|jtgg|���\}}|jdgfi|��\}|d|f}|j|d||jj
g|��i|��y)N�reasonFr)r^rUrcrQr�
rejectJobs)rrIrJr|rbrrGs       rrzConnection.rejectJobs�s���0�T�0�0�#��>��>���T�&�D�&�&��z�:�T�:�	�����'��'��'�'�
�(>��(,�(8�(8�(C�(C�	7�*.�	7�26�	7r(c��d}d}|j|d||jjg|��i|��}i}|�T|j�D]A}t	|�t
jk(rt||�|t|�<�:||||<�C|S)NFrn�ServerGetSettings)rQr�adminGetServerSettingsrxrrrzrU)rrIrJr|rGr}�settingsr]s        rr
z!Connection.adminGetServerSettings�s����
���0��0�0��/B�G�/3�/?�/?�/V�/V�>�15�>�9=�>�������[�[�]�
,����7�d�k�k�)�'*�6�!�9�~�H�S��V�$�"(��)�H�Q�K�	
,��r(c��|jtgg|���\}}|f}|j|d||jjg|��i|��y)N�ServerSetSettings)r^ryrQr�adminSetServerSettings)rrIrJr|rrGs      rrz!Connection.adminSetServerSettings�sa��!4��!4�!4�d�V�!C�d�!C���X��+��'��'�'�
�(;�W�(,�(8�(8�(O�(O�	7�*.�	7�26�	7r(N)'�__name__�
__module__�__qualname__rrr,r5rQr^rcrvr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr
rrnr(rr	r	4s����"2��	�14�h+�\	�([�B7�7�7�O;�d3;�l;�67�7�7�7�7�7�7�7�7�7�$7�7�7�7�7�7�7�7�7�7��&7r(r	)r��sysr�rr�debugr�dbus.mainloop.glibr�	functoolsrr/r0r2r@r	rnr(r�<module>rsH��:
�
�����,��
�T�"�5����5�
�G��w
7�w
7r(

Zerion Mini Shell 1.0