관리-도구
편집 파일: jars.cpython-39.opt-1.pyc
a ����-�_g�����������������������@���s^���d�dl�Z�d�dlZd�dlZd�dlZd�dlZd�dlmZ�d�dlmZm Z m Z �G�dd��dee �ZdS�)�����N)�partial)�Plugin�RedHatPlugin� PluginOptc�������������������@���s^���e�Zd�ZdZdZdZeddedd�edd d d�gZdZ d Z dd��Zdd��Zdd��Z dd��ZdS�)�Jarsz1Collect information about available Java archives�jars)�java�append-locations��z,colon-delimited list of additional JAR paths)�defaultZval_type�desc�all-known-locationsFzscan all known paths)r���r���)z/usr/share/javaz /usr/lib/java)z/optz /usr/localz/var/libc�����������������C���s����dg�i}g�}t�tj�}|��d�r.|t�tj�7�}|��d�}|rJ||�d�7�}|D�]D}t�|�D�]4\}}}|D�]$} |��|| �} |�� | �rj|� | ��qjq\qN|D�]:}|��|�}|��|�} |s�| r�|| |d�}|d�� |��q�t j|ddd�}|�j|d d d��d�S�)Nr���r ���r ����:)�path�sha1�maven_id����)�,�: )�indentZ separatorsz jars.jsonT)Zplug_dir)�listr���� jar_locationsZ get_option�extra_jar_locations�split�os�walkZ path_join�is_jar�append�get_maven_id� get_jar_id�json�dumpsZadd_string_as_file)�self�resultsZ jar_pathsZ locationsZuser_locations�location�dirpath�_� filenames�filenamer����jar_pathr����jar_id�recordZresults_str��r,����;/usr/lib/python3.9/site-packages/sos/report/plugins/jars.py�setup1���s2���� �z Jars.setupc�������������� ���C���s����t�j�|�r�t�|�r�zLt�|��.}d|���v�rBW�d����W�dS�W�d����n1�sV0����Y��W�n@�ttjfy��}�z"|�� d|��d|�����W�Y�d}~n d}~0�0�dS�)z�Check whether given file is a JAR file. JARs are ZIP files which usually include a manifest at the canonical location 'META-INF/MANIFEST.MF'. zMETA-INF/MANIFEST.MFNTzCould not determine if z is a JAR: F) r���r����isfile�zipfile� is_zipfile�ZipFile�namelist�IOErrorZ BadZipfile� _log_info)r"���r����file�errr,���r,���r-���r���T���s����4�zJars.is_jarc����������� ���������sp��i�}�z(t��|���}t�d�����fdd�|���D��}t|�dkrTW�d����W�dS�|�|d����}|���D�]~}|���}|� d�slz6|� d�\}}|�d ����}|�d ����}|||<�W�ql�ty����Y��W�d����W�d����W�dS�0�qlW�d����n1��s0����Y��W�d����n1��s"0����Y��W�n<�t �yj�} �z"|��d |��d| �����W�Y�d} ~ n d} ~ 0�0�|S�)z�Extract Maven coordinates from a given JAR file, if possible. JARs build by Maven (most popular Java build system) contain 'pom.properties' file. We can extract Maven coordinates from there. z*META-INF/maven/[^/]+/[^/]+/pom.properties$c��������������������s���g�|�]}����|�r|�qS�r,���)�match)�.0�x�Zrgxr,���r-���� <listcomp>p��������z%Jars.get_maven_id.<locals>.<listcomp>����Nr�������#����=�utf8z)Could not extract Maven coordinates from r���)r0���r2����re�compiler3����len�open� readlines�strip� startswithr����decode� ValueErrorr4���r5���) r"���r)���Zpropsr6����resultZprops_f�line�key�valuer7���r,���r;���r-���r���e���s.���� j�zJars.get_maven_idc�������������� ���C���s����d}zbt�|dd��:}t���}tt|jd�d�D�]}|�|��q.W�d����n1�sR0����Y��|���}W�n:�ty��}�z"|�� d|��d|�����W�Y�d}~n d}~0�0�|S�) zHCompute JAR id. Returns sha1 hash of a given JAR file. r ����rb)�modei���r=���NzCould not compute JAR id for r���) rE����hashlibr����iterr����read�updateZ hexdigestr4���r5���)r"���r)���r*���r6���Zdigest�bufr7���r,���r,���r-���r�������s����*,zJars.get_jar_idN)�__name__� __module__�__qualname__Z short_descZplugin_nameZprofilesr����strZoption_listr���r���r.���r���r���r���r,���r,���r,���r-���r������s ������ #r���)rQ���r ���r���rB���r0���� functoolsr���Zsos.report.pluginsr���r���r���r���r,���r,���r,���r-����<module>���s���