Current File : //usr/lib/python3/dist-packages/sos/report/plugins/__pycache__/python.cpython-312.pyc
�

-�_g'���ddlZddlZddlZddlmZmZmZmZmZddl	m
Z
Gd�de�ZGd�deee�ZGd�d	ee�Z
y)
�N)�Plugin�RedHatPlugin�DebianPlugin�UbuntuPlugin�	PluginOpt)�
RHELPolicyc�*�eZdZdZdZdZdZdZdZd�Z	y)	�PythonznCaptures information on the installed python runtime(s), as well as
    python modules installed via pip.
    zPython runtime�python)�system)rz	python -Vc���|j|jd��|jd�}|ddk(r0|dj�ddD]}|j|�d���yy)	Nzpython-version)�suggest_filenamezwhereis pip -b�statusr�output�z list installed)�add_cmd_output�python_version�exec_cmd�split)�self�pips�pips   �;/usr/lib/python3/dist-packages/sos/report/plugins/python.py�setupzPython.setup!s}��������2B�	�	
��}�}�-�.����>�Q���H�~�+�+�-�a�b�1�
=���#�#�s�e�?�$;�<�
=�	�N)
�__name__�
__module__�__qualname__�__doc__�
short_desc�plugin_name�profiles�packagesrr�rrr
r
s'���"�J��K��H��H� �N�
=rr
c��eZdZdZdZy)�UbuntuPython�
python3 -V)�python3N)rrrrr#r$rrr&r&.s��!�N��Hrr&c�J��eZdZdZdZeddd��gZ�fd�Zd�Zd	�Z	�xZ
S)
�RedHatPythona In addition to the base information, on Red Hat family distributions the
    python plugin also supports the 'hashes' option. If enabled, this plugin
    will generate a json-formatted listing of all pyfiles within the
    distribution-standard python package installation locations.
    )r�python36�python2r(zplatform-python�hashesFz#collect hashes for all python files)�default�descc����|jddg�t|jt�r$|jj	�dk(rd|_t�|��y)Nz
python2 -Vr'�z/usr/libexec/platform-python -V)r�
isinstance�policyr�dist_versionr�superr)r�	__class__s �rrzRedHatPython.setupAsJ������\�<�8�9��d�k�k�:�.����(�(�*�a�/�"C�D��
��
�rc���|jd�rO|jd�5}|jtj|j�d���ddd�yy#1swYyxYw)Nr-zdigests.json�)�indent)�
get_option�collection_file�write�json�dumps�
get_hashes)r�hfiles  r�collectzRedHatPython.collectHs`���?�?�8�$��%�%�n�5�
E�����D�J�J�t���'8��C�D�
E�
E�%�
E�
E�s�5A"�"A+c	�D�dgi}gd�}|D]�}tj|j|��D]�\}}}|D]�}|jd�s�|j||�}	t	|d�5}	tj�}
|	jd�}|r%|
j|�|	jd�}|r�%|
j�}
|dj||
d��ddd�������|S#1swY�xYw#t$r|jd|���Y��wxYw)	z! Get the hashes for Python files �digests)z/usr/libz
/usr/lib64z/usr/local/libz/usr/local/lib64z.py�rbi)�filepath�sha256NzUnable to read python file at )
�os�walk�	path_join�endswith�open�hashlibrF�read�update�	hexdigest�append�IOError�
_log_error)rrC�py_paths�py_path�root�_�files�_filerE�file�digest�datas            rr?zRedHatPython.get_hashesMs<��
�r�
��
�� �	7�G�"$�'�'�$�.�.��*A�"B�
7���a��"�7�E� �>�>�%�0� �#�~�~�d�E�:�H�7�!�(�D�1��T�%,�^�^�%5�F�#'�9�9�T�?�D�"&� &�
�
�d� 3�'+�y�y����#'�&,�%5�%5�%7�F�#�I�.�5�5�,4�*0�7����7�
7�	7�,�����#�7����(H�+3�*�)6�7�7�s1�#C?�/AC3	�<'C3	�#C?�3C<
�8C?�?D	�D	)rrrrr#r�option_listrrAr?�
__classcell__)r6s@rr*r*4s6����O�H��(�E�<�	>��K�
�E�
"rr*)rLr=rG�sos.report.pluginsrrrrr�sos.policies.distros.redhatrr
r&r*r$rr�<module>r`sG����	�9�9�2�=�V�=�6�6�<���;�6�<�;r