관리-도구
편집 파일: __init__.cpython-39.pyc
a -�_g�# � @ s� d Z ddlZddlZddlZddlZddlZddlmZ ddlZddlZddl Z ddl Z ddlmZ ddlm Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZmZ dd� Z d d � Z!dd� Z"e�#d ej$�Z%dZ&G dd� d�Z'G dd� d�Z(G dd� d�Z)G dd� d�Z*G dd� d�Z+G dd� de+�Z,G dd� de+�Z-G dd� de+�Z.G dd � d e+�Z/G d!d"� d"e+�Z0G d#d$� d$e+�Z1G d%d&� d&e+�Z2G d'd(� d(e+�Z3G d)d*� d*e+�Z4d-d+d,�Z5dS ).z; This exports methods available for use by plugins for sos � N)�time)�datetime)�sos_get_command_output� import_module�grep�fileobj�tail� is_executable�TIMEOUT_DEFAULT�path_exists� path_isdir�path_isfile�path_islink�listdir� path_join�bold�file_is_binary�recursive_dict_values_by_key)�P_FILE�P_LINKc C s^ zBt |��&}t�| |�� tj�W d � W S 1 s60 Y W n tyX g Y S 0 dS )z=Return a list of all non overlapping matches in the string(s)N)r �re�findall�read� MULTILINE�AttributeError)�regex�fname�f� r �?/usr/lib/python3.9/site-packages/sos/report/plugins/__init__.py� regex_findall% s 8r c C s@ t �dd| �}t �dd|�}t �dd|��d�}|d|� }|S ) Nz^/(usr/|)(bin|sbin)/� z[^\w\-\.\/]+�_�/�.z ._-r )r �sub�strip)�command�name_maxZmanglednamer r r �_mangle_command. s r) c C sL t jdft jdft jdft jdfg}|D ]}|d | j�r(|d S q(dS )z� return a string indicating the type of special node represented by the stat buffer st (block, character, fifo, socket). zblock devicezcharacter devicez named pipeZsocketr � r! )�stat�S_ISBLK�S_ISCHR�S_ISFIFO�S_ISSOCK�st_mode)�stZ_types�tr r r � _node_type6 s �r3 z!----(?:-| )BEGIN.*?----(?:-| )ENDz -----SCRUBBEDc @ s� e Zd ZdZdZdZg Zg Zg Zg Z g Z d%dd�Zdd� Zd d � Z dd� Zd d� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd � Zd!d"� Zdg g g g g i fd#d$�ZdS )&�SoSPredicatea� A class to implement collection predicates. A predicate gates the collection of data by an sos plugin. For any `add_cmd_output()`, `add_copy_spec()` or `add_journal()` call, the passed predicate will be evaulated and collection will proceed if the result is `True`, and not otherwise. Predicates may be used to control conditional data collection without the need for explicit conditional blocks in plugins. :param owner: The ``Plugin`` object creating the predicate :type owner: ``Plugin`` :param dry_run: Is sos running in dry_run mode? :type dry_run: ``bool`` :param kmods: Kernel module name(s) to check presence of :type kmods: ``list``, or ``str`` of single name :param services: Service name(s) to check if running :type services: ``list``, or ``str`` of single name :param packages: Package name(s) to check presence of :type packages: ``list``, or ``str`` of single name :param cmd_outputs: Command to run, with output string to check :type cmd_outputs: ``list`` of ``dict``s, or single ``dict`` taking form {'cmd': <command to run>, 'output': <string that output should contain>} :param arch: Architecture(s) that the local system is matched against :type arch: ``list``, or ``str`` of single architecture :param required: For each parameter provided, should the checks require all items, no items, or any items provided :type required: ``dict``, with keys matching parameter names and values being either 'any', 'all', or 'none. Default 'any'. NFr! c s d� d| j � d�}| j}|r.� fdd�|D �n|}|dd�|�� d�7 }| j}|rd� fd d�|D �n|}|d d�|�� d�7 }| j}|r�� fdd�|D �n|}|dd�|�� d�7 }� fd d�| jD �}|dd�|�� d�7 }| j} |r�� fdd�| D �n| } |dd�| �� d�7 }|| | S )zxReturn a string representation of this SoSPredicate with optional prefix, suffix and value quoting. z"%s"zdry_run=�, c s g | ]}� | �qS r r )�.0�k�Zquotesr r � <listcomp>� � z&SoSPredicate.__str.<locals>.<listcomp>zkmods=[�,z], c s g | ]}� | �qS r r )r6 �sr8 r r r9 � r: z services=[c s g | ]}� | �qS r r �r6 �pr8 r r r9 � r: z packages=[c sB g | ]:}d � d � d� |d � d� d � d� |d � d� �qS )z{ �cmd�: r5 �outputz }r )r6 Z cmdoutputr8 r r r9 � s �� �zcmdoutputs=[c s g | ]}� | �qS r r )r6 �ar8 r r r9 � r: zarches=[�])�dry_run�kmods�join�services�packages�cmd_outputs�arch) �self�quote�prefix�suffixZpstrrE rG ZpkgsZ cmdoutputsZarchesr r8 r Z__str� s&