Your IP : 216.73.216.172


Current Path : /lib/python3/dist-packages/sos/report/plugins/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/sos/report/plugins/__pycache__/python.cpython-38.pyc

U

-�_g'�@szddlZddlZddlZddlmZmZmZmZmZddl	m
Z
Gdd�de�ZGdd�deee�ZGdd	�d	ee�Z
dS)
�N)�Plugin�RedHatPlugin�DebianPlugin�UbuntuPlugin�	PluginOpt)�
RHELPolicyc@s,eZdZdZdZdZdZdZdZdd�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 -VcCsT|j|jdd�|�d�}|ddkrP|d��dd�D]}|�|�d��q:dS)	Nzpython-version)Zsuggest_filenamezwhereis pip -bZstatusr�output�z list installed)�add_cmd_output�python_versionZexec_cmd�split)�selfZpipsZpip�r�;/usr/lib/python3/dist-packages/sos/report/plugins/python.py�setup!s�
zPython.setupN)
�__name__�
__module__�__qualname__�__doc__Z
short_descZplugin_nameZprofiles�packagesrrrrrrrsrc@seZdZdZdZdS)�UbuntuPython�
python3 -V)�python3N)rrrrrrrrrr.srcsDeZdZdZdZedddd�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	Zpython36Zpython2rzplatform-python�hashesFz#collect hashes for all python files)�defaultZdesccs<|�ddg�t|jt�r.|j��dkr.d|_t���dS)Nz
python2 -Vr�z/usr/libexec/platform-python -V)r
�
isinstanceZpolicyrZdist_versionr�superr)r��	__class__rrrAs�zRedHatPython.setupc	Cs<|�d�r8|�d��}|�tj|��dd��W5QRXdS)Nrzdigests.json�)�indent)Z
get_optionZcollection_file�write�json�dumps�
get_hashes)rZhfilerrr�collectHs
zRedHatPython.collectcCs�dgi}ddddg}|D]�}t�|�|��D]�\}}}|D]�}|�d�sJq:|�||�}zbt|d��N}	t��}
|	�d�}|r�|
�|�|	�d�}qv|
�	�}
|d�
||
d	��W5QRXWq:tk
r�|�d
|���Yq:Xq:q,q|S)z! Get the hashes for Python files �digestsz/usr/libz
/usr/lib64z/usr/local/libz/usr/local/lib64z.py�rbi)�filepath�sha256zUnable to read python file at )
�os�walkZ	path_join�endswith�open�hashlibr.�read�updateZ	hexdigest�append�IOErrorZ
_log_error)rr+Zpy_pathsZpy_path�root�_�filesZ_filer-�fileZdigest�datarrrr)Ms:��


�zRedHatPython.get_hashes)rrrrrrZoption_listrr*r)�
__classcell__rrr"rr4s��r)r3r'r/Zsos.report.pluginsrrrrrZsos.policies.distros.redhatrrrrrrrr�<module>s