Your IP : 18.227.134.165


Current Path : /opt/imunify360/venv/lib64/python3.11/site-packages/clcommon/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib64/python3.11/site-packages/clcommon/__pycache__/clfunc.cpython-311.pyc

�

\�Dg�����ddlZddlZddlZddlZddlZdZd�Zddddd�Zd	ee	zd
ee	zdzfd�Z
dejfd�Zdejfd
�Z
d�Zd�Zdd�Zdd�Zdd�Zd�Zd�Zd�Zd�Zded
efd�ZdS)�Nz/proc/lve/listc�z�	ttd���5}|�d��}ddd��n#1swxYwYt|�dd��d��dg}nJ#t
$rdd	t��g}Yn2t$rdd
t��g}Ynt$rddt��g}YnwxYw|S)z/
    Obtain lve process filesystem version
    �utf-8��encoding�N�:�r�OKz+clcommon: get_lve_version: Can`t open file z/clcommon: get_lve_version: Can`t get data from z'clcommon: get_lve_version: Can`t parse )�open�LVE_FILE�read�int�rsplit�IOError�
IndexError�
ValueError)�f�line�lve_procfs_versions   �o/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib/python3.11/site-packages/clcommon/clfunc.py�get_lve_versionrsF��	Z�
�(�W�
-�
-�
-�	���6�6�!�9�9�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�!�$�+�+�c�1�"5�"5�a�"8�9�9�4�@�����^�^�^�"�$\�RZ�$\�$\�]�����b�b�b�"�$`�V^�$`�$`�a�����Z�Z�Z�"�$X�h�$X�$X�Y����Z�����s:�A1�:�A1�>�A1�>�.A1�1B8�	B8� B8�7B8r	��i@)�K�M�G�T�val�returnc�(�t|��}tjd��}|�|��}|r@t	|t
tf��rt
|��S|�d��Stjd��}|�|��}|r|�d���d�Stjdtj��}|�|��}|r|�	��\}}}|�|��SdS)z�
    Check that the value is a valid CPU limit (0-100 int or speed (% or MHz/GHz)).
    Return the value if valid, otherwise None.
    If the value contains decimal part, return only integer part.
    z^([1-9][0-9]?|100)(?:\.(\d+))?$r	z"^([1-9]|[1-9][0-9]*)(?:\.(\d+))?%$�%z*^([1-9]|[1-9][0-9]*)(?:\.(\d+))?(mhz|ghz)$N)
�str�re�compile�match�
isinstance�floatr�group�
IGNORECASE�groups)	r�data�
regexp_int�regex_match�
regexp_speedp�
regexp_speedf�integer_part�_�units	         r�validate_cpur3-s���s�8�8�D���>�?�?�J��"�"�4�(�(�K��$��c�E�3�<�(�(�	��s�8�8�O�� � ��#�#�#��J�D�E�E�M��%�%�d�+�+�K��*��#�#�A�&�&�)�)�)�)��J�L�b�m�\�\�M��%�%�d�+�+�K��'� +� 2� 2� 4� 4���a���&��&�&�&��4�c�p�	t|��}n#t$rYdSwxYw||cxkr|krndS|SdS)zH
    Check that val - is a string number
    return val as a string
    N)rr)r�min_val�max_val�dig_vals    r�validate_intr9Msh��
��c�(�(���������t�t������'�$�$�$�$�W�$�$�$�$�$�$��
�%�$s��
 � c�<�	|d}|���rd}||z}tt|dd���t|���zdz��}||cxkr|krnn|Sn#t
ttf$rYnwxYwdS)N���r�)�isdigitrr'�BYTES_CONVERSION_TABLE�upperrr�KeyError)rr6r7�suffix�results     r�memory_to_pagerCZs���	
��R����>�>���	��F���,�C��U�3�s��s�8�_�_�'=�f�l�l�n�n�'M�M�PQ�Q�R�R���f�'�'�'�'��'�'�'�'�'��M����
�H�-�
�
�
���
�����4s�A;A?�?B�Bc��|dkrt|dz��dzS|dkr3ttt|��dzdzd����dzSttt|��dzdzd����d	zS)
N�r<rir�rrr)r"�roundr')�pagess r�page_to_memoryrIhs����s�{�{��5�1�9�~�~��#�#��v�~�~��5��u����)�D�0�!�4�4�5�5��;�;��u�U�5�\�\�A�%��5�q�9�9�:�:�S�@�@r4c�*�tjdd|d|gtj���5}|���d�d��}ddd��n#1swxYwY|D]�}|������}	|d�|�����tj	t|d��tj����#tttf$rY��wxYwdS)Nz/bin/psz-Uz-u)�stdoutr�
r;)�
subprocess�Popen�PIPE�communicate�split�rstrip�index�encode�os�killr�signal�SIGHUPrr�OSError)�item�username�proc�lines�row�partss      r�reload_processesr`psE��	�	�	�D�(�D�(�3���
�
�
�3�
�� � �"�"�1�%�+�+�E�2�2��	3�3�3�3�3�3�3�3�3�3�3����3�3�3�3�
�����
�
���"�"�$�$��	��"�I�O�O�D�K�K�M�M�*�*�*��G�C��a��M�M�6�=�1�1�1�1���J��0�	�	�	��H�	�����s$�.A � A$�'A$�AC6�6D�D�/etc/login.defsc�Z�t|d���5}|D]}}|�d��r�|�dd��d}|���}t|��dkr"|d|kr|dccddd��S�~	ddd��n#1swxYwY|S)Nrr�#r	rrF)r�
startswithrQ�len)�key�default�_path�
login_defs�raw_liner�line_spliteds       rriris��	
�e�g�	&�	&�	&�'�*�"�	'�	'�H��"�"�3�'�'�
���>�>�#�q�)�)�!�,�D��:�:�<�<�L��<� � �A�%�%�,�q�/�S�*@�*@�#�A��&�&�'�'�'�'�'�'�'�'��	'�'�'�'�'�'�'�'�'�'�'�'����'�'�'�'��Ns�A3B �B � B$�'B$�`�c��	ttd����}n#tttf$r|}YnwxYw|S)N�UID_MAX)rrirr�	TypeError)rg�uid_max_s  r�uid_maxrq�sN����z�)�,�,�-�-�����Z��+�������������Os��;�;c�r�tj�|�d���tj|��dS)N�
)�sys�stderr�write�exit)�message�statuss  r�exit_with_errorrz�s4���J����^�^�^�$�$�$��H�V�����r4c��d|vr:	|�d���d��}n#t$rYnwxYw|S)Nz\u�unicode_escaper)�decoderT�UnicodeDecodeError��ss r�safe_escaped_unicode_to_utfr��sW����z�z�	����)�*�*�1�1�'�:�:�A�A��!�	�	�	��D�	�����Hs�(/�
<�<c�\�t|t��rd�|���D��St|t��rd�|D��St|t��rt	d�|D����St|t
��r|���S|S)Nc�N�i|]"\}}t|��t|����#S���byteify��.0rf�values   r�
<dictcomp>zbyteify.<locals>.<dictcomp>�s:��0�0�0��C������g�e�n�n�0�0�0r4c�,�g|]}t|����Sr�r��r��elements  r�
<listcomp>zbyteify.<locals>.<listcomp>�s ��5�5�5�W��� � �5�5�5r4c3�4K�|]}t|��V��dS�Nr�r�s  r�	<genexpr>zbyteify.<locals>.<genexpr>�s*����:�:�'�W�W�%�%�:�:�:�:�:�:r4)r&�dict�items�list�tupler"rT�r+s rr�r��s����$����
�0�0�"&�*�*�,�,�0�0�0�	0�	�D�$�	�	��5�5��5�5�5�5�	�D�%�	 �	 ���:�:�T�:�:�:�:�:�:�	�D�#�	�	���{�{�}�}���r4c�\�t|t��rd�|���D��St|t��rd�|D��St|t��rt	d�|D����St|t
��r|���S|S)Nc�N�i|]"\}}t|��t|����#Sr���
unicodeifyr�s   rr�zunicodeify.<locals>.<dictcomp>�s<��0�0�0��C���3����E�!2�!2�0�0�0r4c�,�g|]}t|����Sr�r�r�s  rr�zunicodeify.<locals>.<listcomp>�s ��8�8�8��
�7�#�#�8�8�8r4c3�4K�|]}t|��V��dSr�r�r�s  rr�zunicodeify.<locals>.<genexpr>�s*����=�=�W�Z��(�(�=�=�=�=�=�=r4)r&r�r�r�r��bytesr}r�s rr�r��s����$����
�0�0�"&�*�*�,�,�0�0�0�	0�	�D�$�	�	��8�8�4�8�8�8�8�	�D�%�	 �	 ���=�=��=�=�=�=�=�=�	�D�%�	 �	 ���{�{�}�}���r4c�|�	|�d����d��dS#t$rYdSwxYw)z�
    Check is string contains only ASCII characters
    :param s: string to check
    :return: True - string contains only ASCII characters
    rr�asciiTF)rTr}r~rs r�is_ascii_stringr��sT���	���'��"�"�)�)�'�2�2�2��t�������u�u����s�)-�
;�;�textc�d�d�}tjd||��}tjdd|��}|S)zG
    Escape '%' characters inside text, except '%' followed by '('
    c�v�|���dd�dz|���dzS)zo
        Generate string to replace from matched string
        '% ' -> '%% '
        '%%c' -> '%%%%c'
        Nr;rF)r()�	match_objs r�replacez(escape_formatting_chars.<locals>.replace�s6����� � ��"��%��)�I�O�O�,=�,=�b�,A�A�Ar4z%+([^(])z%$z%%)r#�sub)r�r�s  r�escape_formatting_charsr��sA��B�B�B��6�+�w��-�-�D�
�6�%���%�%�D��Kr4)Nra)rl)r	)rUr#rWrMrtrrr>r"rr3�maxsizer9rCrIr`rirqrzr�r�r�r�r�r�r4r�<module>r�s���
�	�	�	�	�	�	�	�
�
�
�
�����
�
�
�
������&
�	
�	�	�	����c�C�i��C�#�I��$4�����@ ���
�
�
�
�!"�3�;�����A�A�A����	�	�	�	���������

�
�
�����������#��#������r4

?>