o id@szddlmZmZmZmZmZddlmZddlZddl Z ddl Z GdddeZ Gddde eeZ Gdd d e eZ dS) )Plugin RedHatPlugin DebianPlugin UbuntuPlugin PluginOpt) RHELPolicyNc@s,eZdZdZdZdZdZdZdZddZ d S) PythonznCaptures information on the installed python runtime(s), as well as python modules installed via pip. zPython runtimepython)system)r z python -VcCsV|j|jdd|d}|ddkr'|dddD] }|d|qdSdS) Nzpython-version)suggest_filenamezwhereis pip -bstatusroutputz%s list installed)add_cmd_outputpython_versionexec_cmdsplit)selfpipspipr;/usr/lib/python3/dist-packages/sos/report/plugins/python.pysetup!s  z Python.setupN) __name__ __module__ __qualname____doc__ short_desc plugin_nameprofilespackagesrrrrrrrs rc@seZdZdZdZdS) UbuntuPython python3 -V)python3N)rrrrr rrrrr!.sr!csDeZdZdZdZeddddgZfddZd d Zd d 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 python36python2r#zplatform-pythonhashesFz#collect hashes for all python files)defaultdesccs@|ddgt|jtr|jdkrd|_tt|dS)Nz python2 -Vr"z/usr/libexec/platform-python -V) r isinstancepolicyr dist_versionrsuperr$r)r __class__rrrAs  zRedHatPython.setupcCsV|dr)|d}|tj|ddWddS1s"wYdSdS)Nr'z digests.json)indent) get_optioncollection_filewritejsondumps get_hashes)rhfilerrrcollectHs  "zRedHatPython.collectc Csdgi}gd}|D]m}t||D]b\}}}|D]Z}|ds#q|||}zreadupdate hexdigestappendIOError _log_error) rr;py_pathspy_pathroot_files_filer=fdigestdatarrrr8Ms@         zRedHatPython.get_hashes) rrrrr r option_listrr:r8 __classcell__rrr/rr$4s r$)sos.report.pluginsrrrrrsos.policies.distros.redhatrr?r6rDrr!r$rrrrs