idddlmZmZmZmZmZddlmZddlZddl Z ddl Z GddeZ Gdde eeZ Gdd e eZ y) )Plugin RedHatPlugin DebianPlugin UbuntuPlugin PluginOpt) RHELPolicyNc*eZdZdZdZdZdZdZdZdZ y) PythonznCaptures information on the installed python runtime(s), as well as python modules installed via pip. zPython runtimepython)system)r z python -Vc|j|jd|jd}|ddk(r0|djddD]}|jd|zyy) Nzpython-version)suggest_filenamezwhereis pip -bstatusroutputz%s list installed)add_cmd_outputpython_versionexec_cmdsplit)selfpipspips ;/usr/lib/python3/dist-packages/sos/report/plugins/python.pysetupz Python.setup!s|    2B  }}-. >Q H~++-ab1 ?##$7#$=> ? N) __name__ __module__ __qualname____doc__ short_desc plugin_nameprofilespackagesrrrrr r s'"JKHH N ?rr ceZdZdZdZy) UbuntuPython python3 -V)python3N)rrrrr#r$rrr&r&.s !NHrr&cJeZdZdZdZedddgZfdZdZd 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 python36python2r(zplatform-pythonhashesFz#collect hashes for all python files)defaultdescc|jddgt|jtr$|jj dk(rd|_t t|#y)Nz python2 -Vr'z/usr/libexec/platform-python -V) r isinstancepolicyr dist_versionrsuperr*r)r __class__s rrzRedHatPython.setupAsN \<89 dkk: . ((*a/"CD  lD')rc|jdrO|jd5}|jtj|j ddddyy#1swYyxYw)Nr-z digests.json)indent) get_optioncollection_filewritejsondumps get_hashes)rhfiles rcollectzRedHatPython.collectHs` ??8 $%%n5 E DJJt'8CD E E % E Es 5A""A+c Ddgi}gd}|D]}tj|j|D]\}}}|D]}|jds|j||} t |d5} t j } | jd} | r%| j| | jd} | r%| j} |dj|| dddd|S#1swYxYw#t$r|jd|zYwxYw)Ndigests)z/usr/libz /usr/lib64z/usr/local/libz/usr/local/lib64z.pyrbi)filepathsha256z Unable to read python file at %s) oswalk path_joinendswithopenhashlibrFreadupdate hexdigestappendIOError _log_error) rrCpy_pathspy_pathroot_files_filerEfdigestdatas rr?zRedHatPython.get_hashesMs8 r    4G"$''$..*A"B 4a"4E >>%0 #~~dE:H4!(D1 Q%,^^%5F#$66$K *E !rr*)sos.report.pluginsrrrrrsos.policies.distros.redhatrrGr=rLr r&r*r$rrr`sE992 ?V?66< :6<:r