????

Your IP : 3.141.14.210


Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/__pycache__/clhook.cpython-311.pyc

�

�j�en���ddlmZddlmZddlmZddlZddlZddlZddlZddl	Z	dZ
dZdZdZ
d	�Zd
�Ze
fd�Ze
fd�Ze
fd
�Zd�ZdS)�)�absolute_import)�division)�print_functionNz/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  ��/builddir/build/BUILDROOT/alt-python27-cllib-3.3.15-1.el8.cloudlinux.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/clhook.py�
get_configrs8��
�
&�T�%�
H�
H�
H�F��F��
�K�K�	�����M�c�D�	|dzttj����z}t|d��}|�|��|���t
j||��n'#t$rd|t|��zdzgcYSwxYwddgS)zG
    write config to file_name
    return [BOOLEAN_STATE, MESSAGE]
    �.�wFz
 write error
T�OK
)	r
�os�getpid�open�write�close�shutil�move�IOError)rr�debug_local_name�tmp_cfg_path�	tmpconfigs     r�write_configr$$s���
M� �3���R�Y�[�[�)9�)9�9����c�*�*�	����Y������������L�)�,�,�,�,���M�M�M��'�#�i�.�.�8�;K�K�L�L�L�L�M�����&�>�s�A4A7�7!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/4s����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-r!rr.s      r�
register_hookr8As=��
$�&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)r1rr&r'r(r)�remover3r4r$rr+r*�
ValueErrorr6s      r�unregister_hookr<Vs���
$�&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
���}|j�|��|�
����#t$rd|dzgcYcSwxYwd|t|��zdzgcSddgS)zY
    call hooks and send data as json to stdin 
    return [BOOLEAN_STATUS, message]
    z
call_hook:)�stdin�stdout�stderrFzHook call error
z  : isn`t file or isn`t runnable
Tr)r1�json�dumpsr�path�isfile�access�X_OK�
subprocess�Popen�PIPEr>r�communicate�OSErrorr
)r.�datar!�json_encode�hook�pipes      r�call_hook_listrPfs��
$�l�2���*�T�"�"�K��	_�	_��
�7�>�>�$���	_�B�I�d�B�G�$<�$<�	_�
G�!�'��J�O�j�o�fp�fu�v�v�v���
� � ��-�-�-�� � �"�"�"�"���
G�
G�
G��/�2E�E�F�F�F�F�F�F�
G�����+�c�$�i�i�7�:]�]�^�^�^�^��&�>�s�"A$C�C�C)�
__future__rrrrrrG�
simplejsonrAr�	CL_CONFIGr'r)r1rr$r/r8r<rP�rr�<module>rUs��'�&�&�&�&�&�������%�%�%�%�%�%�	�	�	�	�
�
�
�
�������������'�	�����%�����
�
�
� 8A�
�
�
�
�9B�?�?�?�?�*;D�
�
�
�
� ����r