%PDF- %PDF-
Mini Shell

Mini Shell

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

�

=	f�E���ddlZddlZddlmZmZmZmZmZddl�ddl	�ddl
�ddlmZddl
mZ	ddlZd�ZdZd	ZGd
�de�Zy#e$r
ddlZd�ZY�wxYw)�N)�utils�tui�os_utils�
validation�password)�*)�configparser)�core_installc�H�tj|�j�S�N)�hashlib�sha1�	hexdigest��ss �+/usr/share/hplip/installer/pluginhandler.py�get_checksumr#s���|�|�A��(�(�*�*�c�H�tj|�j�Sr)�sha�newrrs rrr)s���w�w�q�z�#�#�%�%rz/var/lib/hp/hplip.statez.https://developers.hp.com/sites/default/files/c��eZdZejfd�Zd�Zd�Zd�Zdd�Z	d�Z
d�Zdd	�Ze
fd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zy)�PluginHandlec��||_d|_d|_t|_d|_d|_|j�|j�|j�y)N�)
�_PluginHandle__plugin_path�_PluginHandle__required_version�_PluginHandle__plugin_name�PLUGIN_NOT_INSTALLED�_PluginHandle__plugin_state� _PluginHandle__installed_version�_PluginHandle__plugin_conf_file� _PluginHandle__setPluginConfFile�_PluginHandle__setPluginVersion�_PluginHandle__readPluginStatus)�self�
pluginPaths  r�__init__zPluginHandle.__init__3sV��'���"$������2���#%�� �"$���� � �"����!����!rc�f�tjj|dz�stj	d|z�gStj
�}tj|�td�}|jd�}tj�}tj�}tjdd�}tjdd�}tjdd�}	tjdd	�}
tjdd
�}tjdd�}d}
tjdd
�}||	k7r5tj|dz|	dz�tj |	dzd�tj"�}|dk(rd}n|dk(s|dk(s
|dk(s|dk(rd|z}nd|z}|dk(rd}d}nd}d}g}|D�]�}|j%dd�j%dd�}|jd|�j'd�D�]\}|j)|�s3tj+d |z�tj|�gccS|j|d!d�}|j|d"d�}|j|d#d�}|s3tj+d$|z�tj|�gccS|s3tj+d%|z�tj|�gccStjj-tj.|��}tj.|�}|rtj.|�}|j1|||f���_���tj2|�}|j5�tj|�|S)&Nz/plugin.specz#%s/plugin.spec file doesn't exists.zplugin.spec�products�dirs�ppd�drv�home�doc�cupsbackend�
cupsfilterz/etc/udev/rules.d�bini��power_machintosh�ppc�armv6l�armv7l�aarch64�aarch32zarm%dzx86_%d�@z/usr/lib64/sanez
/usr/lib64z
/usr/lib/sanez/usr/libzhp-r�hp_�,zMissing section [%s]�src�trg�linkz$Missing 'src=' value in section [%s]z$Missing 'trg=' value in section [%s])�os�path�exists�log�warn�getcwd�chdir�
ConfigBase�keysr�
getBitness�	getEndian�sys_conf�get�shutil�copyfile�chmod�getProcessor�replace�split�has_section�error�basename�cat�append�
uniqueList�sort)r&�src_dir�cwd�plugin_specr*�BITNESS�ENDIAN�PPDDIR�DRVDIR�HOMEDIR�DOCDIR�CUPSBACKENDDIR�
CUPSFILTERDIR�RULESDIR�BIN�	processor�ARCH�
SANELIBDIR�LIBDIR�copies�PRODUCT�MODELrr<r=r>s                          r�__getPluginFilesListz!PluginHandle.__getPluginFilesList@s
���w�w�~�~�g�n�4�5��H�H�:�7�B�C��I��i�i�k��
����� ��/���#�#�J�/���"�"�$�����"�����f�e�,�����f�e�,���,�,�v�v�.�����f�e�,��!���f�m�<�� ���V�\�:�
�&���l�l�6�5�)���g���O�O�G�N�2�G�N�4J�K��H�H�W�^�+�E�2��&�&�(�	��*�*��D��8�#�y�H�'<�	�Y�@V�Zc�gp�Zp��W�$�D��g�%�D��b�=�*�J�!�F�(�J��F����	0�G��O�O�E�2�.�6�6�u�b�A�E� �_�_�Z��9�?�?��D�
0��"�.�.�q�1��I�I�4�q�8�9��H�H�S�M��I�!�o�o�a���3��!�o�o�a���3��"���q�&�"�5����I�I�D�q�H�I��H�H�S�M��I���I�I�D�q�H�I��H�H�S�M��I��g�g�&�&�u�y�y��~�6���i�i��n��� �9�9�T�?�D��
�
�s�C��.�/�7
0�	0�>�!�!�&�)�����
�
����
��
rc�V�tj|_d|jz|_y)Nzhplip-%s-plugin.run)�prop�installed_versionrr�r&s r�__setPluginVersionzPluginHandle.__setPluginVersion�s#��"&�"8�"8���2�T�5L�5L�L��rc���tt�}|jddt�|_|jtk(rd|_y|jddd�|_tjddd�}|j
|k7rt|_ytjdd�}|j|�}|D]4\}}}|jd	�r�|dk7s�tj|�r�5�6y)
N�plugin�	installedr�version�hplip�0.0.0r+r.z.rules)rF�PLUGIN_STATE_FILErKrr r!rJ�PLUGIN_VERSION_MISMATCH�!_PluginHandle__getPluginFilesList�findr�
check_library)r&�plugin_state_conf�
hplip_versionr.rjr<r=r>s        r�__readPluginStatuszPluginHandle.__readPluginStatus�s���&�(9�:��/�3�3�H�k�K_�`������"6�6�')�D�$�'8�'<�'<�X�i�QS�'T�D�$�$�L�L��)�W�E�M��'�'�=�8�&=��#��|�|�F�F�3���2�2�D�:��&,�!�N�C��d��x�x��)� ��r�z�$�2�2�4�8� �
!rNc�X�tdd}}}|jjd�r2tj�st
j
d�tddfStj�\}}		|jjd�r%tj|j|d�\}}n�tjdd�}|rttj|�d|�d	|j�d
��\}}	|r�t
j
d|z�|||ftj|�tj|�St
j
d�|||ftj|�tj|�Stj j#|�sDt
j
d�|||ftj|�tj|�S	t%|�}|j'|j(dd�}|j'|j(d�}t*}|dk(r3t2||ftj|�tj|�S	tj|�tj|�|||fS#t$r[}
t
j
d
|
jz�|||fcYd}
~
tj|�tj|�Sd}
~
wwxYw#t,t.j0f$rc}
t
j
d|j(�d|
�d��t2||fcYd}
~
tj|�tj|�Sd}
~
wwxYw#tj|�tj|�wxYw)Nrzhttp://z Network connection not detected.r�file://T�wgetz* --tries=3 --timeout=60 --output-document=� z --cache=offz+Plugin download failed with error code = %dz3Please install wget package to download the plugin.z
I/O Error: %szplugin.conf not found.�url�checksumz,Error reading plugin.conf: Missing section [z	]  Error[�])�ERROR_NO_NETWORKr"�
startswithr�check_network_connectionrBrS�make_temp_file�download_from_network�which�runr?�close�remove�IOError�strerrorr@rArFrKr�
ERROR_SUCCESS�KeyErrorr	�NoSectionError�ERROR_FILE_NOT_FOUND)r&�callback�statusr��	check_sum�
local_conf_fp�
local_conf�filenamer��output�e�
plugin_conf_ps            r�__getPluginInformationz#PluginHandle.__getPluginInformation�s���!1�2�b�Y����"�"�-�-�i�8��1�1�3��	�	�<�=�'��Q�.�.�$)�$8�$8�$:�!�
�z�$	"�
.��*�*�5�5�i�@�',�'B�'B�4�CZ�CZ�\f�hl�'m�$�F�H� �;�;�v�t�4�D��).���uy�|F�HL�H_�H_�4`�*a����!��I�I�&S�U[�&[�\�#)�3�	�#9�2
�H�H�]�#��I�I�j�!�1�	�	�"W�X�%�s�I�5�,
�H�H�]�#��I�I�j�!�%�7�7�>�>�*�-��	�	�2�3��s�I�-�
�H�H�]�#��I�I�j�!�
<� *�:� 6�
�#�'�'��(?�(?��r�J��*�.�.�t�/F�/F�
�S�	�&��
�b�y�+�S�)�;�
�H�H�]�#��I�I�j�!��
�H�H�]�#��I�I�j�!��s�I�%�%��1�
.��	�	�/�A�J�J�6�7��s�I�-�-�&
�H�H�]�#��I�I�j�!��-
.���l�9�9�:�
<��	�	�Z^�Zq�Zq�rs�t�u�+�S�)�;�;�
�H�H�]�#��I�I�j�!��
<��
�H�H�]�#��I�I�j�!�sn�1B!J�=J�8M=�%A
K>�/
M=�	K;� &K6�K;�M=�6K;�;M=�>M:�.M5�M:�M=�5M:�:M=�=,N)c��tt|d�j��}tj	d|z�|r||k7rt
t
t
d|�fStj�}|j||�\}}||fS)N�rbzD/L file checksum=%sr)
r�open�readrB�debug�ERROR_CHECKSUM_ERROR�queryStringr�GPG_Verification�validate)r&�plugin_file�digsig_file�req_checksum�
calc_checksum�gpg_obj�
digsig_sts�	error_strs        r�__validatePluginzPluginHandle.__validatePlugin�s���%�T�+�t�%<�%A�%A�%C�D�
��	�	�(�=�8�9��L�M�9�'��5I�1�k�)Z�Z�Z��-�-�/�� '� 0� 0��k� J��
�I��9�$�$rc�X�tjdd�}tjj	d�rd|_ytjj	tjj
|d��r)dtjj
|d�z|_yd|_y)Nr+r.z/etc/hp/plugin.confzfile:///etc/hp/plugin.confzplugin.confr�zhttp://hplip.sf.net/plugin.conf)rJrKr?r@rAr"�join)r&r.s  r�__setPluginConfFilez PluginHandle.__setPluginConfFile�sq���|�|�F�F�+��
�7�7�>�>�/�0�&B�D�#�
�W�W�^�^�B�G�G�L�L��}�=�
>�&/�"�'�'�,�,�t�]�2S�&S�D�#�'H�D�#rc	���tj�}|r|}d}n4|j|�\}}}|}|tk7r|dt	t
d|�fStjd|j�d|�d|j�d��tjj|j|j�}	tjd�tjj|j�s tj |jd�tjj|�rtj"|�tjj|dz�rtj"|dz�	|j/d�rt1j2||d�\}
}�nt1j4d
d�}|rY|�d|j�d|��}
tj|
�t1j6|
�\}
}tjd|
z�
dk7st9j:|�dkr�tjjt<|j�}tj?d|z�|�d|j�d|��}
tj|
�t1j6|
�\}
}|
dk7st9j:|�dkr-tj)d�t@dt	t@d|�fS|jCtE|d�jGd��rBtjd�tj"|�t@dt	t@d|�fS|dz}|dz}tjd|j�d|�d|�d��	|j/d�rt1j2||d�\}
}nA�d|j�d|��}
tj|
�t1j6|
�\}
}|
dk7r0tj)d|z�tH|t	tHd|�fS|jCtE|d�jGd��rZtjtE|d�jG��tj"|�tH|t	tHd|�fS|jK|||�\}}|||fS#t$t&f$rK}	tj)d	|	j*z�t,d|jt	d
�zfcYd}	~	Sd}	~	wwxYw#t&$rD}	tj)d|	j*z�t@dt	t@d|�fcYd}	~	Sd}	~	wwxYw#t&$rG}	tj)d|�d|	j*���tH|t	tHd|�fcYd}	~	Sd}	~	wwxYw)NrrzDownloading z plug-in file from 'z' to 'z'...���.asczFailed in OS operations:%s �fr�Tr�z --cache=off -P r�zwget returned: %dzLPlugin is not accessible. Trying to download it from fallback location: [%s]zPlug-in download failed: %szPlug-in download failed.�riz!open(plugin_file, 'r').read(1024)z& plug-in digital signature file from 'zPlug-in GPG file [z] download failed: z&Plug-in GPG file [%s] download failed.)&r
�CoreInstall�#_PluginHandle__getPluginInformationr�r�r�rBr�rrr?r@r�r�umaskrA�makedirsr��OSErrorr�rSr��ERROR_DIRECTORY_NOT_FOUNDr�rr�r�r�r�getFileSize�PLUGIN_FALLBACK_LOCATION�infor��isErrorPager�r��ERROR_DIGITAL_SIGN_NOT_FOUND�_PluginHandle__validatePlugin)r&r'r��corer<r��stsr�r�r�r�r�r��cmdr��
digsig_urlr�r�s                  r�downloadzPluginHandle.download�s����'�'�)����C��H�!%�!<�!<�X�!F��C��h��C��m�#��B��,@�!�S� I�I�I��	�	��H_�H_�ad�fj�fx�fx�y�z��g�g�l�l�4�#5�#5�t�7I�7I�J��	X��H�H�Q�K��7�7�>�>�$�"4�"4�5����D�.�.��6��w�w�~�~�k�*��	�	�+�&��w�w�~�~�k�&�0�1��	�	�+�f�,�-�	_��~�~�i�(�#(�#>�#>�s�K�QU�#V� ����{�{�6�4�0���7;�D�<N�<N�s�S�C��I�I�c�N�%*�Y�Y�s�^�N�F�F��I�I�1�F�:�;��Q�;�(�"6�"6�{�"C�q�"H��'�'�,�,�'?��AS�AS�T�C��H�H�k�nq�q�r�7;�D�<N�<N�s�S�C��I�I�c�N�%*�Y�Y�s�^�N�F�F��A�:��-�-�k�:�a�?��I�I�0�2�'��[�9M�q�R]�-^�^�^����D��c�2�7�7��=�>��I�I�9�:��I�I�k�"�'��[�9M�q�R]�-^�^�^��6�\�
�!�F�*���	�	�Z^�Zq�Zq�s}�@K�L�	M�		x��$�$�Y�/�#(�#>�#>�z�;�X\�#]� ���37��8J�8J�:�V���	�	�#��!&���3�����
�A�:��I�I�>�*�M�N�/��k�Jf�hi�kv�>w�w�w����D��c�2�7�7��=�>��I�I�d�;��,�1�1�3�4��I�I�k�"�/��k�Jf�hi�kv�>w�w�w��.�.�{�K��R���Y��K��*�*��A��!�	X��I�I�3�A�J�J�>�?�,�b�$�2D�2D�{�SV�GW�2W�W�W��	X��0�	_��I�I�3�a�j�j�@�A�'��[�9M�q�R]�-^�^�^��	_��4�	x��I�I�Z�PQ�PZ�PZ�[�\�/��k�Jf�hi�kv�>w�w�w��	x�s^�8CS2�EU�1A-V�2U�AU�U�U�	V�9V�V�V�	W/�(<W*�$W/�*W/c���d}tjd||fz�tj�}tj|j
�tj}|tk(rd|�d|��}tj|�}nd|�d|��}tj|�}|dk(rd}ntjd�d}tjd	�tj|�|S)
NFz"run_plugin plugin_file =%s mode=%dzsh z --keep --nox11 -- -u z --keep --nox11 -- -i rTz(Python gobject/dbus may be not installedz./plugin_tmp)rBr�r?rDrEr�sys�
executable�GUI_MODEr�executerSrr�)r&r��mode�resultrZ�exec_strr�r�s        r�
run_pluginzPluginHandle.run_pluginZs������	�	�6��T�7J�J�K��i�i�k��
����#�#�$��>�>���8��5@�(�K�C��%�%�c�*�F��6A�(�K�C��%�%�c�*�F��Q�;��F��I�I�@�A��F�	���^�$�
����
��
rc��|j|�}tjd�|D�]h\}}}tjj	|�st
j
d|z��@tjj	|�r-t
j
d|z�tj|�tjj|�}tjj	|�s.t
j
d|z�tj|d�tjj|�st
jd|z���1	tj||�tjj	|�st
jd|z����tj|tj tj"ztj$ztj&ztj(z�|s���tjj	|�r*t
j
d�tj|�t
j
d	|�d
|�d��	tj*||���kt
j
d�t3t4�}|j7ddd�t
j
d�|j7ddd�t8j;ddd�}	t
j
d|	z�|j7dd|	�t<|_|	|_ y#t,t.f$r-}t
j
d|j0z�Yd}~��Wd}~wwxYw#t.t,f$r-}t
jd
|j0z�Yd}~���d}~wwxYw)Nrz(Source file %s does not exist. Skipping.z)Target file %s already exists. Replacing.z-Target directory %s does not exist. Creating.r�z<Target directory %s exists but is not a directory. Skipping.z0Target file %s does not exist. File copy failed.z"Symlink already exists. Replacing.zCreating symlink z (link) to file z (target)...zUnable to create symlink: %szFile copy failed: %sz$Updating hplip.state - installed = 1rtru�1zUpdating hplip.state - eula = 1�eularwrvrxz#Updating hplip.state - version = %sT)!r{r?r�r@rArBr�r��dirnamer��isdirrSrLrMrN�stat�S_IRWXU�S_IRGRP�S_IXGRP�S_IROTH�S_IXOTH�symlinkr�r�r�rFry�setrJrK�PLUGIN_INSTALLEDr r!)
r&rYrjr<r=r>�trg_dirr�r~rs
          r�	copyFileszPluginHandle.copyFilesus����*�*�7�3��
�����$�,	�N�C��d��7�7�>�>�#�&��	�	�D�s�J�K���w�w�~�~�c�"��	�	�E��K�L��	�	�#���g�g�o�o�c�*�G��7�7�>�>�'�*��	�	�I�G�S�T����G�U�+��7�7�=�=��)��	�	�X�[b�b�c��
�����S�)��w�w�~�~�c�*��I�I�P�SV�V�W���H�H�S�$�,�,����"=����"L�t�|�|�"[�^b�^j�^j�"j�k���w�w�~�~�d�+��	�	�"F�G��	�	�$���I�I�TX�Z]�^�_���
�
�3��-�S,	�\	�	�	�8�9�&�(9�:�����h��S�9��	�	�3�4����h���4� ���W�i��A�
��	�	�7�
�E�F����h�y�-�@�.���#0�� ���!$�W�-���	�	�"@�1�:�:�"M�N�����)�W�%�
��	�	�0�1�:�:�=�>���
�s0�N�<M	�	N�"N�N�O�"N?�?Oc�R�tjdd�}|j|�}t|�dk(rtjd�y|D]W\}}}tjd|�d|�d��|d	k7rt
j|�|d	k7s�Ct
j|��Yy
)Nr+r.rzFail to get Plugin files listFz	Deleting r;z files.rT)rJrKr{�lenrBr�r?�unlink)r&r.�filesr<r=r>s      r�	uninstallzPluginHandle.uninstall�s����|�|�F�F�+���)�)�$�/���u�:��?��I�I�5�6��#�	 �N�C��d��I�I�s�4�8�9��b�y��	�	�#���r�z��	�	�$��	 �rc��|jSr)r!rqs r�getInstalledVersionz PluginHandle.getInstalledVersion�s���'�'�'rc�~�|j�tjd|jz�|jS)NzPlugin status = %s)r%rBr�r rqs r�	getStatuszPluginHandle.getStatus�s2�����!��	�	�&�t�':�':�:�;��"�"�"rc��|jSr)rrqs r�getFileNamezPluginHandle.getFileName�s���!�!�!rc���|dz}tjj|�rtj|�tjj|�rtj|�yy)Nr�)r?r@rAr�)r&r�r�s   r�deleteInstallationFilesz$PluginHandle.deleteInstallationFiles�sI��!�F�*��
�7�7�>�>�+�&��I�I�k�"�
�7�7�>�>�+�&��I�I�k�"�'rr)rN)�__name__�
__module__�__qualname__ro�user_dirr(r{r$r%r�r�r#r�r�r�r�r�r�r�r�r��rrrr2sa��$(�M�M�
"�N�bM�
!�.0&�f%�
H� X+�v,4��6?�D�$(�#�"�#rr)r?rL�baserrrrr�base.g�
base.codes�base.strings�base.sixext.movesr	�	installerr
r
r�ImportErrorrryr��objectrr�rr�<module>r�sd��,
�
�;�;����*�"�
&��+�.��K��k#�6�k#���&��&�&�s�A
�
A�A

Zerion Mini Shell 1.0