| Current Path : /usr/lib/python3/dist-packages/sos/report/plugins/__pycache__/ |
| Current File : //usr/lib/python3/dist-packages/sos/report/plugins/__pycache__/python.cpython-38.pyc |
U
���b � @ 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 -bZstatusr �output� z%s list installed)�add_cmd_output�python_versionZexec_cmd�split)�selfZpipsZpip� r �;/usr/lib/python3/dist-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 s4 e Zd ZdZdZedddd�gZ� fdd�Z� ZS ) �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
sB | � ddg� t| jt�r.| j�� dkr.d| _tt| ��� | � d��r>dg i}ddd d
g}|D ]�}t
�| �|��D ]�\}}}|D ]�}| �||�}|�
d�r�z`t|d��L} t�� }
d
}| �|�}|r�|
�|� q�q�q�|
�� }
|d �||
d�� W 5 Q R X W q� tk
�r | �d| � Y q�X q�qtq`| jt�|�ddd� d S )Nz
python2 -Vr � z/usr/libexec/platform-python -Vr �digestsz/usr/libz
/usr/lib64z/usr/local/libz/usr/local/lib64z.py�rbi )�filepath�sha256z Unable to read python file at %szdigests.jsonT)Zplug_dir)r
�
isinstanceZpolicyr Zdist_versionr �superr r Z
get_option�os�walkZ path_join�endswith�open�hashlibr# �read�updateZ hexdigest�append�IOErrorZ
_log_errorZadd_string_as_file�json�dumps)
r r Zpy_pathsZpy_path�root�_�filesZfile_r"