%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/share/hplip/base/__pycache__/
Upload File :
Create Path :
Current File : //usr/share/hplip/base/__pycache__/module.cpython-312.pyc

�

=	f�q��l�ddlZddlZddlZddlZddl�ddlmZmZmZdZ	dZ
dZdZdZ
Gd�d	e�Zy)
�N�)�*)�tui�utils�device��Fc���eZdZ			d
d�Z		dd�Z				dd�Zd�Zdd�Zdd�Zdde	je	jddfd	�Ze	je	jdfd
�Z
dd�Zd�Zy)�ModuleNc��||_||_||_||_||_tjd�tj|�g|_	|	|_
|
|_d|_d|_
tjdt _tj$d�rtj'd�||_|�"||_t-|j*�|_ng|_d|_t0j3ddd�|_d|_g|_t;j<t0j3dd	d
��r4|j8j?t@�|xj6dz
c_t;j<t0j3ddd
��r4|j8j?tB�|xj6dz
c_t;j<t0j3ddd
��r4|j8j?tD�|xj6dz
c_tF|_$d|_%|j(��tL|j(vr1t jNr!|j8r|xjJdz
c_%tF|j(vr|xjJdz
c_%tP|j(vr|xjJdz
c_%|j(�;tF|j(vrtF|_$ntP|j(vrtP|_$|j*���t jN�r�|j8�r�|j4d	k(rJtB|j*vr8t@|j*vr&tF|j(vrtF|_$d
|_�nYtB|j*vr!|j4dk(rtB|j8vsft@|j*vr!|j4d	k(rt@|j8vs3tD|j*vr.|j4dk(rtD|j8vr
tL|_$�n�|j4d	k(r�t@|j*vr�tB|j*vr$tB|j8vrd|_tL|_$tD|j*vr&tD|j8vrd|_tL|_$�n$tF|j(vr
tF|_$�ntP|j(vrtP|_$n�tjSd|jz�d|_
n�|j4dk(r�tB|j*vr�t@|j*vr%t@|j8vrd	|_tL|_$netF|j(vrtF|_$nGtP|j(vrtP|_$n)tjSd|jz�d|_
|jH|_*tjV�dk(r|stjYd|z�yyy)N�Fr�HPLIP_DEBUG�debug�	configurez
ui-toolkit�qt4�qt3�0r�qt5�nonez#%s cannot be run using Qt3 toolkit.Tz#%s cannot be run using Qt4 toolkit.z'%s should not be run as root/superuser.)-�mod�title�version�doc�
usage_data�os�umask�log�
set_module�args�quiet�
deprecated�	lock_file�help_only_support�sys�argv�prop�prog�getenv�	set_level�avail_modes�supported_ui_toolkits�len�num_supported_ui_toolkits�sys_conf�get�default_ui_toolkit�num_installed_ui_toolkits�installed_ui_toolkitsr�to_bool�append�UI_TOOLKIT_QT3�UI_TOOLKIT_QT4�UI_TOOLKIT_QT5�INTERACTIVE_MODE�default_mode�num_valid_modes�GUI_MODE�	gui_build�NON_INTERACTIVE_MODE�error�mode�getuid�warn)�selfrrrrrr*r+�run_as_root_okr r!s           �/usr/share/hplip/base/module.py�__init__zModule.__init__(s���
�����
�������$���
��������s����	���
�$������!&����H�H�Q�K��	�
�9�9�]�#��M�M�'�"�&��� �,�)>�D�&�-0��1K�1K�-L�D�*�)+�D�&�-.�D�*�"*�,�,�{�L�%�"P���)*��&�%'��"��=�=����k�5�#�>�?��&�&�-�-�n�=��*�*�a�/�*��=�=����k�5�#�>�?��&�&�-�-�n�=��*�*�a�/�*��=�=����k�5�#�>�?��&�&�-�-�n�=��*�*�a�/�*�,��� ������'��4�+�+�+����4�C]�C]��$�$��)�$��4�#3�#3�3��$�$��)�$�#�t�'7�'7�7��$�$��)�$����'��4�#3�#3�3�$4��!�%��)9�)9�9�$8��!��%�%�1�d�n�n��Ic�Ic��&�&�%�/�N�d�F`�F`�4`��d�&@�&@�@�EU�Y]�Yi�Yi�Ei�%5��!�*0��'� �D�$>�$>�>�4�CZ�CZ�^c�Cc�hv�z~�{U�{U�iU� �D�$>�$>�>�4�CZ�CZ�^c�Cc�hv�z~�{U�{U�iU� �D�$>�$>�>�4�CZ�CZ�^c�Cc�hv�z~�{U�{U�iU�$,��!��(�(�E�1�n�D�Lf�Lf�6f�!�T�%?�%?�?�N�VZ�Vp�Vp�Dp�.3�D�+�(0�D�%�!�T�%?�%?�?�N�VZ�Vp�Vp�Dp�.3�D�+�(0�D�%�%��)9�)9�9�(8�D�%�)�T�-=�-=�=�(<�D�%��I�I�C�d�h�h�N�O�-1�D�*��(�(�E�1�n�D�Lf�Lf�6f�!�T�%?�%?�?�N�VZ�Vp�Vp�Dp�.3�D�+�(0�D�%�%��)9�)9�9�(8�D�%�)�T�-=�-=�=�(<�D�%��I�I�C�d�h�h�N�O�-1�D�*��%�%��	�
�9�9�;�!��N��H�H�>��D�E�%3��c�F
�|jr|jdddfg|_ng|_d|jg}g}g}|tztk(rn|j	d�|j	t
j�|j	t
j�|j	t
j�|j��|jdkD�r|j	d�|j	t
j�|j	t
j�|jdkDrAt|jvr/tj r|j	t
j"�t$|jvr|j	t
j&�t(|jvr|j	t
j*�|j	d�|j	t
j�|j	t
j,�|j��t|jv�r|j.��|j0dkDr�tj r�|jdkDr�t2|j.vr1t2|j4vr|j	t
j6�t8|j.vr1t8|j4vr|j	t
j:�t<|j.vr1t<|j4vr|j	t
j>�|j	t
j@�|j	t
jB�|tDztDk7r|j	t
jF�|j	t
jH�|�|D]}|j	|��|tJzr|j	d	�|�|rp|j	t
j�|j	t
jL�|D]}	|j	|	��|�|D]}	|j	|	��|�Z|j	t
j�|j	t
jN�|D]}
|j	|
dd
df��|jQddjS|�dd
df�|D]}|jj	|��y)N��nameTzUsage:z[DEVICE_URI|PRINTER_NAME]rz[MODE]z	[OPTIONS]z[FILES]�seealsoF� �summary)*rrr�USAGE_FLAG_DEVICE_ARGSr4r�
USAGE_ARGS�USAGE_DEVICE�
USAGE_PRINTERr*r:�USAGE_SPACE�
USAGE_MODEr1r;r&r<�USAGE_GUI_MODEr8�USAGE_INTERACTIVE_MODEr=�USAGE_NON_INTERACTIVE_MODE�
USAGE_OPTIONSr+r-r5r2�
USAGE_USE_QT3r6�
USAGE_USE_QT4r7�
USAGE_USE_QT5�USAGE_LOGGING1�USAGE_LOGGING2�USAGE_FLAG_SUPRESS_G_DEBUG_FLAG�USAGE_LOGGING3�
USAGE_HELP�USAGE_FLAG_FILE_ARGS�USAGE_NOTES�
USAGE_SEEALSO�insert�join)rB�
include_flags�
extra_options�extra_notes�
see_also_listrL�content�notes�e�n�s�cs            rD�setUsagezModule.setUsage�s����8�8� $���"�f�d�;�<�D�O� �D�O��T�X�X�&�������1�1�5K�K��N�N�6�7��N�N�5�+�+�,��N�N�5�-�-�.��N�N�5�.�.�/����'�D�,@�,@�1�,D��N�N�8�$��N�N�5�,�,�-��N�N�5�+�+�,��-�-��1��t�/�/�/�D�N�N��N�N�5�#7�#7�8��4�#3�#3�3����u�;�;�<�#�t�'7�'7�7����u�?�?�@�	���{�#����u�(�(�)����u�*�*�+����'�H��8H�8H�,H��&�&�2�t�7U�7U�XY�7Y��N�N�t�=�=��A���!;�!;�;��RV�Rl�Rl�@l����u�2�2�3���!;�!;�;��RV�Rl�Rl�@l����u�2�2�3���!;�!;�;��RV�Rl�Rl�@l����u�2�2�3�	���u�+�+�,����u�+�+�,��:�:�>]�]��N�N�5�/�/�0�	���u�'�'�(��$�"�
"�����q�!�
"��/�/��N�N�9�%��"�e��N�N�5�,�,�-��N�N�5�,�,�-��
"�����q�!�
"��&�$�&�A��N�N�1�%�&��$��N�N�5�,�,�-��N�N�5�.�.�/�"�
:������2�y�%�8�9�
:�	���q�3�8�8�G�,�b�)�T�B�C��	&�A��O�O�"�"�1�%�	&rFTc��d}|sdj|dg�}gd�}|r&dj|dg�}|jgd��|jdkDr�t|jvr6t
jr&dj|dg�}|jd	d
g�t|jvr&dj|dg�}|jdd
g�t|jvr&dj|dg�}|jgd��|j��|jdk\r�t
jr�|j��t|jvr�t|jvr%t|jvr|jddg�t|jvr%t|jvr|jddg�t|jvr%t|jvr|jddg�|�dj||g�}|�|j|�d}d}d}	d}
d}g}|j}
t
jr
|j }nd}d}	t#j"t$j&dd||�\}|_|D�]�\}}|dvr|}	�|dvr|}
�|dvr7|j+�j-�}t.j1|�r�Md
}�P|dvrt.j1d��j|dvrS|j�5t|jvr#|j�t
jrt}
��|j3d���|d vr)|j���t|jvs��t}
d}��|d!vr+|j���t|jvs��t}
d}��|d"vrd
}��%|d#k(rd$}��.|d%k(rd&}��7|d'k(rd(}��@|d)k(rd*}��I|d+vr�|j���[t|jvs��o|j�>t|jvr,t
jrt|jvr
t}
d}���|j3d,|j4z����|d-vr�|j����t|jvs���|j�>t|jvr,t
jrt|jvr
t}
d}��I|j3d.|j4z���i|d/vs��o|j���}t|jvs���|j�>t|jvr,t
jrt|jvr
t}
d}���|j3d.|j4z����	|rd
}|j:rT|s|r|dk(rb|j=||�nOt.j?t.jAd0|j4z��d
}n|dk(r|j=||�|�t%jBd�|
|_"||	|
|
||fS#t"j6$r}|j8g}Yd}~��d}~wwxYw)1Nzl:hrH�g)zlogging=�helpz	help-restzhelp-manz	help-descr�dbgzd:p:P:)zdevice=zdevice-uri=zprinter=zprinter-namer�u�gui�ui�i�interactive�textrk)�noninteractiveznon-interactive�batchrrzuse-qt3rzuse-qt4rzuse-qt5Fr)z-dz--devicez--device-uri)z-Pz-pz	--printerz--printer-name)z-lz	--logging)z-gz--debugz--dbgr)z-uz--guiz--uizUnable to enter GUI mode.)z-iz
--interactivez--text)z-nz--non-interactivez--batch)z-hz--helpz--help-rest�restz
--help-man�manz--help-desc�descz--uiscanT)z--qt3z	--use-qt3z2%s does not support Qt3. Unable to enter GUI mode.)z--qt4z	--use-qt4z2%s does not support Qt4. Unable to enter GUI mode.)z--qt5z	--use-qt5z
Please check usage '%s --help')#rc�extendr:r;r*r&r<r8r=r+r-r5r2r6r7r9r0�getoptr$r%r�lower�striprr)r4r�GetoptError�msgr#�usage�info�bold�exitr?)rB�extra_params�extra_long_params�handle_device_printer�supress_g_debug_flag�params�long_params�opts�
show_usage�
device_uri�printer_name�uiscan�	error_msgr?�
ui_toolkit�lang�o�a�	log_levelrjs                    rD�parseStdOptszModule.parseStdOptss���
��#��W�W�f�c�]�+�F�'��
!��W�W�f�h�/�0�F����U�V����!�#��4�+�+�+�������&�#��/���"�"�E�4�=�1��4�#3�#3�3����&�#��/���"�"�M�6�#:�;�#�t�'7�'7�7����&�#��/���"�"�#Q�R��%�%�1��*�*�a�/�D�N�N����(�X��9I�9I�-I���!;�!;�;��RV�Rl�Rl�@l��"�"�E�9�#5�6���!;�!;�;��RV�Rl�Rl�@l��"�"�E�9�#5�6���!;�!;�;��RV�Rl�Rl�@l��"�"�E�9�#5�6��#��W�W�f�l�3�4�F��(����0�1����
��
������	�� � ���>�>��0�0�J��J���T	n�$�m�m�C�H�H�Q�R�L�&�+�N�O�D�$�)�
�N
n���1��:�:�!"�J��E�E�#$�L��-�-� !���	��� 1�I��=�=��3�%+�
��4�4��M�M�'�*��1�1��'�'�3��D�DT�DT�8T��2�2�>�4�>�>�'��!�(�(�)D�E��;�;��'�'�3�8H�D�L\�L\�8\�/��%+�
��@�@��'�'�3�8L�PT�P`�P`�8`�3��%+�
��*�*�!'�J��-�'�!'�J��,�&�!&�J��-�'�!'�J��*�_�!�F��0�0��'�'�3��D�DT�DT�8T��5�5�A�*�d�.H�.H�H�T�^�^�*�d�.H�.H�H�#+�D�).�J�%�,�,�-a�dh�dl�dl�-l�m��0�0��'�'�3��D�DT�DT�8T��5�5�A�*�d�.H�.H�H�T�^�^�*�d�.H�.H�H�#+�D�).�J�%�,�,�-a�dh�dl�dl�-l�m��0�0��'�'�3��D�DT�DT�8T��5�5�A�*�d�.H�.H�H�T�^�^�*�d�.H�.H�H�#+�D�).�J�%�,�,�-a�dh�dl�dl�-l�m�]N
n�r��J��!�!��Y��U�?��J�J�z�9�5�������"D�T�X�X�"M�N�O�#�
�����
�
�:�y�1��!��H�H�Q�K���	��Z��t�Z��E�E��_�!�!�	 �����I��	 �s�0X+�+Y�>
Y�Yc	���tj�}d|_ttj��D]-\}}|j
|ddj|dd�f��/|j�y)N)z
Language CodezAlternate Name(s)r�, r)	r�	Formatter�header�list�supported_locales�items�addrc�output)rB�f�loc�lls    rD�
showLanguageszModule.showLanguages�se���M�M�O��9����-�3�3�5�6�	.�G�C��
�E�E�2�a�5�$�)�)�B�q�r�F�+�,�-�	.�	
���
rFc��|�|js|j�y|dk(r$|j�tj�|dk(rt	|j
�yt
j|j||j|j|j�|r1|D]}tj|��tjd�tjd�|dk(rtjd�yy)Nrxr}rr)r �	showTitlerr��printrr�format_textrrrrr>r$r�)rBr�r�rjs    rDr�zModule.usage�s������:�:���� ������N�N���H�H�J�����$�(�(�O�
���d�o�o�z�4�:�:�t�x�x�QU�Q]�Q]�^��"�!�A��I�I�a�L�!�������H�H�Q�K��V�#������$rFc�>�|j�s�tjd�|r:tjtjdtj
z��n(tjtjd��tjtj|j�d|j
����tjd�tjd�tjd�tjd�tjd�tjd�|jrKtjtjd	|jz��tjd�yyy)
NrHz.HP Linux Imaging and Printing System (ver. %s)z$HP Linux Imaging and Printing Systemz ver. z0Copyright (c) 2001-18 HP Development Company, LPz0This software comes with ABSOLUTELY NO WARRANTY.z;This is free software, and you are welcome to distribute itz<under certain conditions. See COPYING file for more details.zZ%s support is deprecated. Feature can be used as is. Fixes or updates will not be provided)	r rr�r�r&rrr!rA)rB�show_vers  rDr�zModule.showTitle�s���z�z��H�H�R�L�����#�(�(�#S�VZ�Vb�Vb�#b�c�d����#�(�(�#I�J�K�
�H�H�S�X�X�d�j�j�$�,�,�G�H�I��H�H�R�L��H�H�G�H��H�H�G�H��H�H�R�S��H�H�S�T��H�H�R�L����������"~�AE�AK�AK�#K�L�M�������%rFc��tjd|�d|�d|�d|�d|�d��tjd|jz�d}d|vrd}d}d}	d	}
|�Etj||�}tj|�|s|rtjd
�y	|�$||vrd}n|rtjd|z�y	d}|��tj|�|D]�}tj|�tj|�\	}}
}}}}}}}tjd|�d
|
�d|�d|�d|�d|�d|�d|�d|���||}|j�|D�cgc]}|j���c}vs��d}	|x}}d}��|	durtjd|z�d	}|ry	|�|�|r|}
ny|�0|�.|rs|	rq|k(r|}
nitjd|�d|�d��d\}}nG|�|�|	rtj||�}
n*t|�dk(rt|j��d}
|
�Qt|�rF|jtk(rtj||�}
nt|j��d}
|
�tj!dd|
�|
S|jtt"fvr*tjd�t%j&d�|
Scc}w)aD Validate passed in parameters, and, if in text mode, have user select desired device to use.
            Used for tools that are device-centric and accept -d (and maybe also -p).
            Use the filter(s) to restrict what constitute valid devices.

            Return the matching device URI based on:
            1. Passed in device_uri if it is valid (filter passes)
            2. Corresponding device_uri from the printer_name if it is valid (filter passes) ('*' means default printer)
            3. User input from menu (based on bus and filter)

            device_uri and printer_name can both be specified if they correspond to the same device.

            Returns:
                device_uri|None
                (returns None if passed in device_uri is invalid or printer_name doesn't correspond to device_uri)
        z
getDeviceUri(r�z, , �)�Mode=%sF�hpaioTN�*No device found that support this feature.�@'%s' device doesn't support this feature (or) Invalid device URIz	back_end=z, is_hp=z, bb=z, model=z	, serial=z, dev_file=z, host=z, zc=z, port= �B'%s' device doesn't support this feature (or) Invalid printer namez
Printer name z and device URI z refer to different devices.)NNrr�	last_usedr�zANo device selected/specified or that supports this functionality.)rrr?r�getSupportedCUPSDevicesr>�parseDeviceURIr��getDeviceURIByPrinterNamer,r��keysr8r�device_table�	user_conf�setr=r$r�)rBr�r��back_end_filter�filter�devices�restrict_to_installed_devices�
scan_uri_flag�
device_uri_ok�printer_name_ok�device_uri_ret�uri�back_end�is_hp�bb�model�serial�dev_file�host�zc�port�cups_printer�m�printer_name_device_uris                        rD�getDeviceUrizModule.getDeviceUri�s���$	�	�	�
����@]�_�	`��	�	�)�d�i�i�'�(��
��o�%� �M��
������?��4�4�_�f�M�G��I�I�g���<��	�	�F�G���!��W�$� $�
�.��	�	�\�_i�i�j��!%�
��#��I�I�g���	
(���y�y��~�"�1�1�#�6�L�x���E�6�8�T�2�t��y�y�w�BG�IK�MR�TZ�\d�fj�ln�pt�u�v�%�c�l�|��$�$�&�l�*K��1�7�7�9�*K�K�%)�?�:=�=�*�Z�#'�=�	
(��d�*��y�y�]�`l�l�m�"�|�/���!�l�&:�}�'�N�
�
#��(@����!8�8�%/�N��I�I�am�oy�z�{�1;�.�L�,�
�
�L�$<��#�=�=�l�M�Z�N�
��\�Q�
�!�'�,�,�.�1�!�4�N��!�c�'�l��y�y�,�,�!$�!1�!1�'�=�!I��!%�g�l�l�n�!5�a�!8���%��M�M�+�|�^�D���
�y�y�-�/C�D�D��	�	�]�^���������[+Ls�Kc�j�tjd|�d|�d|�d|�d�	�tjd|jz�d}d}d}d}	tj||�}
tj|
�|
stjd�y|�<tj||�}||vrd	}|}	ntjd
|z�d}|ry|��|dk(r3dd
lm}|j�}
|
�|
}n{tjd�d}nc|j�|
D�cgc]}|j���c}vrd	}tj|�}	ntjd|z�d}|ry|�|�|rt|�dk(rK||d}nB|�$|�"|r<|r:||	k(r|}n2tjd�n|�|�|r|}nt|
�dk(r|
d}|�8|jttfvr t|
�rtj |
�}|�|	�tj|�}	|	�t"j%dd|	�|�t"j%dd|�nX|jttfvr+tjd�t'j(d�ntjd�d	||	fScc}w)a� Validate passed in parameters, and, if in text mode, have user select desired printer to use.
            Used for tools that are printer queue-centric and accept -p (and maybe also -d).
            Use the filter(s) to restrict what constitute valid printers.

            Return the matching printer_name based on:
            1. Passed in printer_name if it is valid (filter passes) ('*' means default printer)
            2. From single printer_name of corresponding passed in device_uri (filter passes)
            3. User input from menu (CUPS printer list, filtered) [or if > 1 queue for device_uri]

            device_uri and printer_name can both be specified if they correspond to the same device.

            Returns:
                (printer_name|None, device_uri|None) (tuple)
                (returns None if passed in printer_name is invalid or device_uri doesn't correspond to printer_name)
        zgetPrinterName(r�r�r�FNr�)FNNTr�rr)�cupszCUPS default printer not setr�rz7Printer name and device URI refer to different devices.r�r�r�zBNo printer selected/specified or that supports this functionality.zNo printer selected/specified)rrr?r�getSupportedCUPSPrinterNamesr>r��prntr��getDefaultPrinterr�r�r,r8r=r�
printer_tabler�r�r$r�)rBr�r�r�r�r�r�r��printer_name_retr��printersr�r��default_printer�ps               rD�getPrinterNamezModule.getPrinterName`s���$	�	�	�j�,�P_�ag�h�i��	�	�)�d�i�i�'�(��
��������6�6���O���	�	�(����I�I�B�C�$��!��4�4�_�f�M�G��W�$� $�
�!+���	�	�\�_i�i�j�!�
�0�,��#��s�"�%�"&�"8�"8�":��"�.�'6�$��I�I�<�=�#'�L� �%�%�'�x�+H�!�A�G�G�I�+H�H�&*�O�%+�%E�%E�l�%S�N��I�I�b�eq�q�r�#'�L�4�0��!�l�&:�}��7�:�&�'�1�,�#*�:�#6�q�#9� �
�
#��(@�����/�'3�$��I�I�W�X�
�
�L�$<��+��
��]�a�
�'��{���#��	�	�6F�H\�5]�(]�be�fn�bo�"�0�0��:���'�N�,B�#�=�=�>N�O�N��%��M�M�+�|�^�D��'��M�M�+�~�7G�H��y�y�-�/C�D�D��	�	�^�_�������	�	�9�:��%�~�5�5��[,Is�J0c��|r:tjdj|j|g�|�\}|_n(tj|j|�\}|_|stjd�yy)N�-r)r�lock_apprcrr"r$r�)rB�suffix�suppress_error�oks    rD�lockInstancezModule.lockInstance�s\���!&������$�(�(�F�9K�0L�^�!\��B���!&�������!H��B�����H�H�Q�K�rFc�\�|j� tj|j�yy)N)r"r�unlock)rBs rD�unlockInstancezModule.unlockInstance�s!���>�>�%��L�L����(�&rF)NNNFFF)rNNN)NNTF)rxN)T)rHF)�__name__�
__module__�__qualname__rErnr�r�r�r�r�DEFAULT_BE_FILTER�DEFAULT_FILTERr�r�r�r��rFrDrr's���.2�'+�?D�|F�~7;�15�]&�@)-�'+�+/�*/�pF�f��8�0'+��v�Og�Og�"�1�1�4�_c�f�RHN�G_�G_�$�3�3�SW�d6�N�)rFr)r$�rerrrprHrrr�USAGE_FLAG_NONErMr\r_r��objectrr�rFrD�<module>r�sJ��.�	�
�	�� � �����"&����
��l
)�V�l
)rF

Zerion Mini Shell 1.0