Sindbad~EG File Manager

Current Path : /lib/python3.6/site-packages/sos/report/plugins/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/sos/report/plugins/__pycache__/python.cpython-36.opt-1.pyc

3

�f(�@szddlZddlZddlZddlmZmZmZmZmZddl	m
Z
Gdd�de�ZGdd�deee�ZGdd	�d	ee�Z
dS)
�N)�Plugin�RedHatPlugin�DebianPlugin�UbuntuPlugin�	PluginOpt)�
RHELPolicyc@s,eZdZdZdZdZd	Zd
ZdZdd�Z	dS)�PythonznCaptures information on the installed python runtime(s), as well as
    python modules installed via pip.
    zPython runtime�python�systemz	python -VcCsV|j|jdd�|jd�}|ddkrRx*|dj�dd�D]}|jd|�q<WdS)	Nzpython-version)Zsuggest_filenamezwhereis pip -bZstatusr�output�z%s list installed)�add_cmd_output�python_versionZexec_cmd�split)�selfZpipsZpip�r�/usr/lib/python3.6/python.py�setup!s
zPython.setupN)r
)r	)
�__name__�
__module__�__qualname__�__doc__Z
short_descZplugin_nameZprofiles�packagesrrrrrrrsrc@seZdZdZdZdS)�UbuntuPythonz
python3 -V�python3N)r)rrrrrrrrrr.srcsDeZdZdZdZeddd	d
�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	�python36�python2r�platform-python�hashesFz#collect hashes for all python files)�defaultZdesccs<|jddg�t|jt�r.|jj�dkr.d|_t�j�dS)Nz
python2 -Vz
python3 -V�z/usr/libexec/platform-python -V)r
�
isinstanceZpolicyrZdist_versionr�superr)r)�	__class__rrrAs
zRedHatPython.setupcCs<|jd�r8|jd��}|jtj|j�dd��WdQRXdS)Nrzdigests.json�)�indent)Z
get_optionZcollection_file�write�json�dumps�
get_hashes)rZhfilerrr�collectHs
zRedHatPython.collectcCs�dgi}ddddg}x�|D]�}x�tj|j|��D]�\}}}x�|D]�}|jd�sPq@|j||�}yft|d��R}	tj�}
|	jd�}x|r�|
j|�|	jd�}q~W|
j	�}
|dj
||
d	��Wd
QRXWq@tk
r�|jd|�Yq@Xq@Wq0WqW|S)z! Get the hashes for Python files �digestsz/usr/libz
/usr/lib64z/usr/local/libz/usr/local/lib64z.py�rbi)�filepath�sha256Nz Unable to read python file at %s)
�os�walkZ	path_join�endswith�open�hashlibr/�read�updateZ	hexdigest�append�IOErrorZ
_log_error)rr,Zpy_pathsZpy_path�root�_�filesZ_filer.�fileZdigest�datarrrr*Ms4




zRedHatPython.get_hashes)r	rrrr)rrrrrrZoption_listrr+r*�
__classcell__rr)r$rr4s
r)r4r(r0Zsos.report.pluginsrrrrrZsos.policies.distros.redhatrrrrrrrr�<module>s

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists