← Back
Editing: jars.cpython-38.pyc
U O6uf� � @ 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)�selfZresultsZ jar_pathsZ locationsZuser_locations�location�dirpath�_� filenames�filenamer �jar_pathr �jar_id�recordZresults_str� r+ �9/usr/lib/python3/dist-packages/sos/report/plugins/jars.py�setup1 s2 �z Jars.setupc C s� t j�|�r�t�|�r�z6t�|��"}d|�� kr@W 5 Q R � W dS W 5 Q R X W n> ttjfk r� } z| � d|� d|� �� W 5 d}~X Y nX 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.MFTzCould not determine if z is a JAR: NF) r r �isfile�zipfileZ is_zipfile�ZipFile�namelist�IOErrorZ BadZipfile� _log_info)r"