File: //lib/python3.9/site-packages/sos/report/plugins/__pycache__/python.cpython-39.pyc
a
^��c � @ sz d dl mZmZmZmZmZ d dlmZ d dlZd dl Z d dl
Z
G dd� de�ZG dd� deee�ZG dd � d ee�Z
dS )
� )�Plugin�RedHatPlugin�DebianPlugin�UbuntuPlugin� PluginOpt)�
RHELPolicyNc @ s, e Zd ZdZdZdZdZdZdZdd� Z d S )
�PythonznCaptures information on the installed python runtime(s), as well as
python modules installed via pip.
zPython runtime�python)�system)r z python -Vc C sR | j | jdd� | �d�}|d dkrN|d �� dd � D ]}| � d| � q:d S ) Nzpython-version)Zsuggest_filenamezwhereis pip -b�statusr �output� z%s list installed)�add_cmd_output�python_versionZexec_cmd�split)�selfZpipsZpip� r �=/usr/lib/python3.9/site-packages/sos/report/plugins/python.py�setup! s �
zPython.setupN)
�__name__�
__module__�__qualname__�__doc__Z
short_descZplugin_nameZprofiles�packagesr r r r r r r s r c @ s e Zd ZdZdZdS )�UbuntuPython�
python3 -V)�python3N)r r r r r r r r r r . s r c sD e Zd ZdZdZedddd�gZ� fdd�Zd d
� Zdd� Z � Z
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 Zpython36Zpython2r zplatform-python�hashesFz#collect hashes for all python files)�defaultZdescc s@ | � ddg� t| jt�r.| j�� dkr.d| _tt| ��� d S )Nz
python2 -Vr � z/usr/libexec/platform-python -V) r �
isinstanceZpolicyr Zdist_versionr �superr r )r �� __class__r r r A s �zRedHatPython.setupc C sP | � d�rL| �d��(}|�tj| �� dd�� W d � n1 sB0 Y d S )Nr zdigests.json� )�indent)Z
get_optionZcollection_file�write�json�dumps�
get_hashes)r Zhfiler r r �collectH s
zRedHatPython.collectc C s� dg i}g d�}|D ]�}t �| �|��D ]�\}}}|D ]�}|�d�sFq6| �||�}zvt|d��X} t�� }
| �d�}|r�|
�|� | �d�}qr|
� � }
|d �
||
d�� W d � n1 s�0 Y W q6 ty� | �d| � Y q60 q6q(q|S )N�digests)z/usr/libz
/usr/lib64z/usr/local/libz/usr/local/lib64z.py�rbi )�filepath�sha256z Unable to read python file at %s)
�os�walkZ path_join�endswith�open�hashlibr/ �read�update� hexdigest�append�IOErrorZ
_log_error)r r, Zpy_pathsZpy_path�root�_�filesZ_filer. �f�digest�datar r r r* M s4 �
�*�zRedHatPython.get_hashes)r r r r r r Zoption_listr r+ r* �
__classcell__r r r# r r 4 s ��r )Zsos.report.pluginsr r r r r Zsos.policies.distros.redhatr r0 r( r4 r r r r r r r �<module> s