Your IP : 3.138.113.44


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__/clhook.cpython-311.pyc

�

\�Dgt��n�ddlZddlZddlZddlZddlZdZdZdZdZ	d�Z
d�Zefd�Zefd	�Z
efd
�Zd�ZdS)�Nz/etc/sysconfig/cloudlinux�hooks�;zpython-cllib:clhook:c�t�tjdd���}t|_|�|��|S)z6
    read config from file_name
    return config
    NF)�
interpolation�strict)�configparser�ConfigParser�str�optionxform�read)�	file_name�configs  �o/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib/python3.11/site-packages/clcommon/clhook.py�
get_configrs8��
�
&�T�%�
H�
H�
H�F��F��
�K�K�	�����M�c�D�	|�dtj����}t|dd���5}|�|��ddd��n#1swxYwYt	j||��n/#t$r"}d|�|�dt|����gcYd}~Sd}~wwxYwdd	gS)
zG
    write config to file_name
    return [BOOLEAN_STATE, MESSAGE]
    �.�wzutf-8)�encodingNFz
 write error
T�OK
)�os�getpid�open�write�shutil�move�IOErrorr
)rr
�debug_local_name�tmp_cfg_path�	tmpconfig�es      r�write_configr"!s��
O�#�3�3�b�i�k�k�3�3��
�,��g�
6�
6�
6�	$�)��L�L��#�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$���L�)�,�,�,�,���O�O�O��*�M�I�M�M�S��V�V�M�M�N�N�N�N�N�N�N�����O�����&�>�s@�*A/�A�A/�A�A/�A�A/�/
B�9B�B�Bc���g}t|��}	|�t|���t��}n%#t
jt
jf$rd|gcYSwxYwd|gS)z+
    return [BOOLEAN_STATE, hook_list]
    FT)r�get�HOOK_SECTION�split�HOOK_SEPARATORr�
NoOptionError�NoSectionError)�hook_prefix�config_file�	hook_listrs    r�get_hook_list_from_filer-0s����I�
��
$�
$�F�"��J�J�|�[�9�9�?�?��O�O�	�	���&��(C�D�"�"�"��y�!�!�!�!�"�����)��s�3A�A)�(A)c�|�tdz}t|��}	|�t|���t
��}||vrd|dzt
|��zdzgS|�|��|�t|t
�	|����nw#tj$r9|�t��|�t||��Yn0tj
$r|�t||��YnwxYwt|||��S)zE
    add hook to config file
    return [BOOLEAN_STATE, MESSAGE]
    zregister_hook:TzHook z already registred
)�DEBUG_STRINGrr$r%r&r'r
�append�set�joinrr)�add_sectionr(r"��	hook_pathr*r+rrr,s      r�
register_hookr6=s=��
$�&6�6��
��
$�
$�F�
9��J�J�|�[�9�9�?�?��O�O�	��	�!�!��*�W�4�s�9�~�~�E�H^�^�`�`�����#�#�#��
�
�<��n�.A�.A�)�.L�.L�M�M�M�M���&�9�9�9����<�(�(�(��
�
�<��i�8�8�8�8�8��%�9�9�9��
�
�<��i�8�8�8�8�8�9�������-=�>�>�>s �AB6�,A	B6�6AD*�=*D*�)D*c��tdz}t|��}	|�t|���t
��}|�|��|�t|t
�|����t|||��S#tjtjtf$rddgcYSwxYw)zJ
    remove hook from config_file
    return [BOOLEAN_STATE, MESSAGE]
    zunregister_hook:Tr)r/rr$r%r&r'�remover1r2r"rr)r(�
ValueErrorr4s      r�unregister_hookr:Rs���
$�&8�8��
��
$�
$�F���J�J�|�[�9�9�?�?��O�O�	�����#�#�#��
�
�<��n�.A�.A�)�.L�.L�M�M�M��F�K�1A�B�B�B���'��)C�Z�P�����f�~�������s�BB(�(%C�Cc�*�tdz}tj|��}|D]�}tj�|��r�tj|tj��r�	tj	|tj
tj
tj
���5}|j�|��|�
��ddd��n#1swxYwY��#t$rd|dzgcYcSwxYwd|t|��zdzgcSddgS)	zX
    call hooks and send data as json to stdin
    return [BOOLEAN_STATUS, message]
    z
call_hook:)�stdin�stdout�stderrNFzHook call error
z  : isn`t file or isn`t runnable
Tr)r/�json�dumpsr�path�isfile�access�X_OK�
subprocess�Popen�PIPEr<r�communicate�OSErrorr
)r,�datar�json_encode�hook�procs      r�call_hook_listrNbsx��
$�l�2���*�T�"�"�K��_�_��
�7�>�>�$���
	_�B�I�d�B�G�$<�$<�
	_�

G��%��$�/�%�?�%�?�	���'�
��J�$�$�[�1�1�1��$�$�&�&�&�'�'�'�'�'�'�'�'�'�'�'����'�'�'�'����
G�
G�
G��/�2E�E�F�F�F�F�F�F�
G�����+�c�$�i�i�7�:]�]�^�^�^�^��&�>�s6�"6C�/C�C�C	�C�C	�C�C5�4C5)rrrE�
simplejsonr?r�	CL_CONFIGr%r'r/rr"r-r6r:rN�rr�<module>rRs���
�	�	�	�
�
�
�
�������������'�	�����%��������8A�
�
�
�
�9B�?�?�?�?�*;D�
�
�
�
� ����r

?>