| Current Path : /lib/python3/dist-packages/sos/report/plugins/__pycache__/ |
| Current File : //lib/python3/dist-packages/sos/report/plugins/__pycache__/__init__.cpython-38.pyc |
U
���b| � @ s� d Z ddlmZmZmZmZmZmZmZm Z m
Z
mZmZm
Z
mZmZmZmZ ddlmZ ddlZddlZddlZddlZddlmZ ddlZddlZddlZddlZddlmZ dd� Zd d
� Zdd� Z e�!d
ej"�Z#dZ$G dd� de%�Z&G dd� de%�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*�Z/G d#d$� d$e*�Z0G d%d&� d&e*�Z1G d'd(� d(e*�Z2G d)d*� d*e+�Z3d-d+d,�Z4dS ).z; This exports methods available for use by plugins for sos � )�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_FILEN)�time)�datetimec
C sT z6t |��$}t�| |�� tj�W 5 Q R � W S Q R X W n tk
rN g Y S X 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/dist-packages/sos/report/plugins/__init__.py�
regex_findall! s
,r 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 � N)�stat�S_ISBLK�S_ISCHR�S_ISFIFO�S_ISSOCK�st_mode)�stZ_types�tr r r �
_node_type2 s �r2 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 }| j}|r*� fdd�|D �n|}|dd�|� 7 }| j}|r\� fdd�|D �n|}|dd�|� 7 }| j}|r�� fd d�|D �n|}|d
d�|� 7 }� fdd�| jD �}|dd�|� 7 }| j} |r� fd
d�| D �n| } |dd�| � 7 }|| | S )zxReturn a string representation of this SoSPredicate with
optional prefix, suffix and value quoting.
z"%s"zdry_run=%s, c s g | ]}� | �qS r r )�.0�k�Zquotesr r �
<listcomp>� s z&SoSPredicate.__str.<locals>.<listcomp>zkmods=[%s], �,c s g | ]}� | �qS r r �r4 �sr6 r r r7 � s zservices=[%s], c s g | ]}� | �qS r r �r4 �pr6 r r r7 � s zpackages=[%s], c s4 g | ],}d � d � |d � d � |d f �qS )z{ %s: %s, %s: %s }�cmd�outputr )r4 Z cmdoutputr6 r r r7 � s �
�zcmdoutputs=[%s], c s g | ]}� | �qS r r )r4 �ar6 r r r7 � s zarches=[%s])�dry_run�kmods�join�services�packages�cmd_outputs�arch)
�self�quote�prefix�suffixZpstrrA rC ZpkgsZ
cmdoutputsZarchesr r6 r Z__str� s&