관리-도구
편집 파일: 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"