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

�

Hf�+��b�ddlZddlmZddlmZddlZddlZejd�ddlZddlm	Z	ddl
Z
ddlZeje
je
j��Gd�dej�Zed	k(r1Gd
�d�ZddlmZed
�e�ej&�yy)�N)�GObject)�Gtkz1.9.52��
debugprint)�domain�	localedirc��eZdZdZdej
jddfiZ			dd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�
PPDsLoadera
    1. If PackageKit support is available, and this is a local server,
    try to use PackageKit to install relevant drivers.  We do this
    because we can only make the right choice about the "best" driver
    when the full complement of drivers is there to choose from.

    2. Fetch the list of available drivers from CUPS.

    3. If Jockey is available, and there is no appropriate driver
    available, try to use Jockey to install one.

    4. If Jockey was able to install one, fetch the list of available
    drivers again.
    �finishedN�c�B�tjj|�td|z�||_||_||_||_||_||_||_	g|_
d|_d|_d|_
d|_d|_d|_|jduxs#|jdk(xs|jddk(|_	t%j&�|_t+d�}t-j.|ddt,j0j2t,j4j6|�	�|_|j8j;t+d
��|j8j=d|j>�y#td�d|_Y��xYw)Nz+%sF�	localhostr�/zFailed to get session bus�	SearchingT)�parent�modal�destroy_with_parent�message_type�buttons�textzSearching for drivers�response) r�__init__r�
_device_id�_device_uri�_device_make_and_model�_parent�_host�_encryption�	_language�_installed_files�_conn�_ppds�_exc�_ppdsmatch_result�_jockey_queried�_jockey_has_answered�_local_cups�dbus�
SessionBus�_bus�_r�
MessageDialog�MessageType�INFO�ButtonsType�CANCEL�_dialog�format_secondary_text�connect�_dialog_response)	�self�	device_idr�
device_uri�host�
encryption�language�device_make_and_model�fmts	         �./usr/share/system-config-printer/ppdsloader.pyrzPPDsLoader.__init__8sd��	��� � �$�'��E�D�L�!�#���%���&;��#������
�%���!��� "�����
���
���	�!%���$���$)��!� �J�J�$�.�1� �J�J�+�5�1� �J�J�q�M�S�0�	
��	����*�D�I�
��n���(�(��04�$�7:���7K�7K�25�/�/�2H�2H�/2�	4���	
���*�*�A�.E�,F�G������j�$�*?�*?�@��	��3�4��D�I�s�	F�Fc��|jj�|jr$tj|j�|_|jro|jrc|j
drT|j
drE|jr9d|j
d�d|j
d�d�|_|j�y|j�y)N�MFG�MDLzMFG:z;MDL:�;)r1�show_allr�cupshelpers�
parseDeviceID�_devid_dictr'r*�_gpk_device_id�_query_packagekit�_query_cups�r5s r=�runzPPDsLoader.runas�������� ��?�?�*�8�8�$�/�/�J�D������O�O����U�#����U�#��I�I�6:�6F�6F�u�6M�6:�6F�6F�u�6M�#O�D���"�"�%�����c� �td|z�y)Nz-%srrIs r=�__del__zPPDsLoader.__del__rs���E�D�L�!rKc���td|z�|jr!|jj�d|_d|_|jr"|jj�d|_yy)NzDESTROY: %s)rr1�destroyrr!rIs r=rOzPPDsLoader.destroyusW���M�D�(�)��<�<��L�L� � �#��D�L�����:�:��J�J���!��D�J�rKc��|jS�N)r rIs r=�get_installed_fileszPPDsLoader.get_installed_files�s���$�$�$rKc��|jSrQ)r"rIs r=�get_ppdszPPDsLoader.get_ppds�s���z�z�rKc��|jSrQ)r$rIs r=�get_ppdsmatch_resultzPPDsLoader.get_ppdsmatch_result�s���%�%�%rKc�`�t|�dt|j����|jS)Nz: stored error is )r�reprr#rIs r=�	get_errorzPPDsLoader.get_error�s"����d�D�I�I�6F�G�H��y�y�rKc�T�|j�d|_|jd�y�Nr)rOr1�emit)r5�dialogrs   r=r4zPPDsLoader._dialog_response�s����������	�	�:�rKc��td�|jsItj|j|j
|j|j��}||_y|j
|jd�y)NzAsking CUPS for PPDs)r8r9�
reply_handler�
error_handler)rr!�	asyncconn�
Connectionrr�_cups_connect_reply�_cups_error)r5�cs  r=rHzPPDsLoader._query_cups�sa���*�+��
�
��$�$�4�:�:�15�1A�1A�48�4L�4L�48�4D�4D�F�A��D�J��$�$�T�Z�Z��6rKc��|jtd��|j|j|j��y)Nz
fetching PPDs)r_r`)�_begin_operationr+�getPPDs2�_cups_replyrd)r5�conn�UNUSEDs   r=rczPPDsLoader._cups_connect_reply�s7�����q��1�2��
�
�T�%5�%5�%)�%5�%5�	�	7rKc�n�tjj||j��}||_d|_|j�r|j|jd|jd|jd|jd|j|j�}|jt|j��|j|j|��}||f|_|d}|j rb||j#d	�sN|j$sB|jdr3|jdr$|j&rd
|_|j)�y|j+�d|_|j.�!|j.j+�d|_|j1d�y)N)r:Fr?r@�DES�CMD)�devid�fitr�exactTr)rC�ppds�PPDsrr"�_need_requery_cupsr�getPPDNamesFromDeviceIDrErr�orderPPDNamesByPreference�list�keysr r$r*�
startswithr%r'�
_query_jockeyrOr!r1r\)r5rj�resultrrrp�ppdnamelist�ppdnames       r=rizPPDsLoader._cups_reply�s������$�$�f�t�~�~�$�F����
�"'����?�?��'�'��)9�)9�%�)@�)-�)9�)9�%�)@�)-�)9�)9�%�)@�)-�)9�)9�%�)@�)-�)9�)9�)-�)D�)D�F�
��)�)�4�����+<�+/�+@�+@�15�1A�1A�/2�*�4�
�
'*�;�%7�D�"�!�!�n�G��	�	���L�+�+�W�5��(�(�� � ��'�� � ��'�� � �(,��$��"�"�%��������
��<�<�#��L�L� � �#��D�L��	�	�:�rKc���|j�d|_d|_||_|j�!|jj�d|_|jd�yr[)rOr!r"r#r1r\)r5rj�excs   r=rdzPPDsLoader._cups_error�sM��������
���
���	��<�<�#��L�L� � �#��D�L��	�	�:�rKc
�J�td�	|jjdd�}tj|d�}|j
g}d}tdt
d��dt
|��dt
|��d	��|jtjd�|||j|jd
��y#t$r\}tdt
|�z�|jr/|jj�|j�Yd}~yYd}~yd}~wwxYw)
Nz$Asking PackageKit to install driverszorg.freedesktop.PackageKitz/org/freedesktop/PackageKitz!org.freedesktop.PackageKit.Modifyz
hide-finishedzCalling InstallPrinterDrivers (rz, �)��r_r`�timeoutz Failed to talk to PackageKit: %s)rr*�
get_objectr(�	InterfacerFrX�InstallPrinterDrivers�UInt32�_packagekit_reply�_packagekit_error�	Exceptionr1rBrH)r5�obj�proxy�	resources�interaction�es      r=rGzPPDsLoader._query_packagekit�s����:�;�	$��)�)�&�&�(D�(E�G�C��N�N�C�)L�M�E��,�,�-�I�)�K���q��4��#3�T�;�5G�I�
J��'�'����a��)2�K�7;�7M�7M�7;�7M�7M�15�	
(�
7��
�	$��:�T�1�X�E�F��|�|����%�%�(�� � �#�#���	$�s�B/B=�=	D"�A
D�D"c��td�d|_|jr+|jj�|j	�yy)NzGot PackageKit replyT)rrtr1rBrHrIs r=r�zPPDsLoader._packagekit_reply�s;���*�+�"&����<�<��L�L�!�!�$�����rKc��tdt|�z�|jr+|jj�|j	�yy)NzGot PackageKit error: %s)rrXr1rBrH�r5rs  r=r�zPPDsLoader._packagekit_error�s<���.��s��;�<��<�<��L�L�!�!�$�����rKc�:�td�	|jjdd�}tj|d�}|jd|jz|j|jd��}y#t$r}|j|�Yd}~yd}~wwxYw)Nz Asking Jockey to install driverszcom.ubuntu.DeviceDriverz/GUIzprinter_deviceid:%sr�r�)
rr*r�r(r��
search_driverr�
_jockey_reply�
_jockey_errorr�)r5r��jockey�rr�s     r=rzzPPDsLoader._query_jockey�s����6�7�	#��)�)�&�&�(A�6�J�C��^�^�S�*C�D�F��$�$�&;�d�o�o�&M�48�4F�4F�48�4F�4F�.2�%�4�A���	#�����"�"��	#�s�A(A6�6	B�?B�Bc��tdt|�z�d|_	|d|_|j	�y#g|_Y�xYw)NzGot Jockey result: %sT�)rrXr&r rH)r5rjr{s   r=r�zPPDsLoader._jockey_replysJ���+�d�F�m�;�<�$(��!�	'�$*�1�I�D�!�	
�����	'�$&�D�!�s	�
;�	Ac�B�tdt|�z�|jr|j�y|j�!|jj�d|_|j�!|jj�d|_|jd�y)NzGot Jockey error: %sr)rrXrtrHr!rOr1r\r�s  r=r�zPPDsLoader._jockey_errorsw���*�T�3�Z�7�8��"�"������z�z�%��
�
�"�"�%�!��
��|�|�'����$�$�'�#����I�I�z�"rK)NNNNNNN)�__name__�
__module__�__qualname__�__doc__r�SignalFlags�RUN_LAST�__gsignals__rrJrMrOrRrTrVrYr4rHrcrirdrGr�r�rzr�r�rrKr=r
r
$s���
� 	�W�(�(�1�1�4��<�
�L�AE�7;�(,�'A�R �""�
�%��&���
	7�7�
(�T	�$�* � �
#��
#rKr
�__main__c��eZdZd�Zd�Zd�Zy)�Fooc�2�tj�}tjjd�}|j	|�|jd|j�|jdtj�|j�||_	y)N�Go�clickedzdelete-event)
r�Window�Button�new_with_label�addr3�go�	main_quitrB�_window)r5�w�bs   r=rzFoo.__init__ s`���
�
�
�A��
�
�)�)�4�0�A�
�E�E�1�I�
�I�I�y�$�'�'�*�
�I�I�~�s�}�}�5�
�J�J�M��D�LrKc��td|j��}|jd|j�|j	�y)NzMFG:MFG;MDL:MDL;)r6rr)r
r�r3�ppds_loadedrJ)r5�button�loaders   r=r�zFoo.go)s3���+=�(,���6�F��N�N�J��(8�(8�9��J�J�MrKc��|jj�tj�|j	�}t|�|j
�}|�tt|��|j�yrQ)r�rOrr�rY�printrT�len)r5�
ppdsloaderrrrs    r=r�zFoo.ppds_loaded/s]���L�L� � �#��M�M���&�&�)�C��#�J��&�&�)�D����c�4�j�!����!rKN)r�r�r�rr�r�rrKr=r�r�s��	�	�		"rKr�)�
set_debuggingT)r(�
gi.repositoryrrrC�cups�requirera�debugr�config�gettext�install�PACKAGErr
r�r�r��mainrrKr=�<module>r�s���,�!��������h����
������v�~�~��1A�1A�B�x#����x#�t�z��"�"�6$��4���F��C�H�H�K�?rK

Zerion Mini Shell 1.0