Current File : //usr/lib/python3/dist-packages/sos/report/plugins/__pycache__/__init__.cpython-312.pyc |
�
-�_g�# � �B � d Z ddlZddlZddlZddlZddlZddlmZ ddlZddlZddl Z ddl
Z
ddlmZ ddlm
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZmZ d� Z d� Z!d � Z" ejF d
ejH � Z%dZ& G d� d
� Z' G d� d� Z( G d� d� Z) G d� d� Z* G d� d� Z+ G d� de+� Z, G d� de+� Z- G d� de+� Z. G d� de+� Z/ G d� de+� Z0 G d � d!e+� Z1 G d"� d#e+� Z2 G d$� d%e+� Z3 G d&� d'e+� Z4d)d(�Z5y)*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 �� � t |� 5 }t j | |j � t j � cddd� S # 1 sw Y yxY w# t
$ r g cY S w xY w)z=Return a list of all non overlapping matches in the string(s)N)r �re�findall�read� MULTILINE�AttributeError)�regex�fname�fs �=/usr/lib/python3/dist-packages/sos/report/plugins/__init__.py�
regex_findallr! % sR � ��
�U�^� =�q��:�:�e�Q�V�V�X�r�|�|�<� =� =� =��� �� ��s. �A �3A
� A �
A�A �A �A$�#A$c � � t j dd| � }t j dd|� }t j dd|� j d� }|d| }|S ) Nz^/(usr/|)(bin|sbin)/� z[^\w\-\.\/]+�_�/�.z ._-r )r �sub�strip)�command�name_max�manglednames r �_mangle_commandr, . sV � ��&�&�0�"�g�>�K��&�&��#�{�;�K��&�&��s�K�0�6�6�v�>�K��a��)�K��� c �� � t j dft j dft j dft j dfg}|D ] } |d | j
� s�|d c S y)z� return a string indicating the type of special node represented by
the stat buffer st (block, character, fifo, socket).
zblock devicezcharacter devicez
named pipe�socketr � r# )�stat�S_ISBLK�S_ISCHR�S_ISFIFO�S_ISSOCK�st_mode)�st�_types�ts r �
_node_typer: 6 sm � �
���~�&�
���)�*�
����%�
����!� �F� � ���1�Q�4��
�
���Q�4�K�� r- z!----(?:-| )BEGIN.*?----(?:-| )ENDz
-----SCRUBBEDc � � e Zd ZdZdZdZg Zg Zg Zg Z g Z
dd�Zd� Zd� Z
d� Zd� Zd � Zd
� Zd� Zd� Zd
� Zd� Zd� Zd� Zd� Zd� Zdg g g g g i fd�Zy)�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'.
NFc
�� � d}d| j � d�}| j }|r|D �cg c] }||z �� c}n|}|ddj |� � d�z
}| j }|r|D � cg c] } || z �� c} n|}|ddj |� � d�z
}| j }
|r|
D �cg c] }||z �� c}n|
}
|ddj |
� � d�z
}| j
D �cg c]# }d |d
z � d||d
z � d|dz � d||d z � d
� ��% }
}|ddj |
� � d�z
}| j }|r|D �cg c] }||z �� c}n|}|ddj |� � d�z
}||z |z S c c}w c c} w c c}w c c}w c c}w )zxReturn a string representation of this SoSPredicate with
optional prefix, suffix and value quoting.
z"%s"zdry_run=�, zkmods=[�,z], z
services=[z
packages=[z{ �cmd�: �outputz }zcmdoutputs=[zarches=[�])�dry_run�kmods�join�services�packages�cmd_outputs�arch)�self�quote�prefix�suffix�quotes�pstrrE �krG �s�pkgs�p� cmdoutput�
cmdoutputs�arches�as r �__strzSoSPredicate.__str� s� � � ���$�,�,��r�*���
�
��/4�U�+���!��+�%���'�#�(�(�5�/�*�#�.�.���=�=��5:��1�1�F�Q�J�1����*�S�X�X�h�/�0��4�4���}�}��-2�D�)�q���
�)����*�S�X�X�d�^�,�C�0�0��
"�-�-�
� � �&�5�.�!��F�Y�u�-=�$=�#>�b��� �!��F�Y�x�-@�$@�#A��
F�
�
�
�
�,�s�x�x�
�3�4�C�8�8������16�f�-��&�1�*�-�F���(�3�8�8�F�+�,�A�.�.����}�v�%�%��- ,�� 2�� *��
�� .s �E� E�E!�(E&�&E+c �"