JFIF$        dd7 

Viewing File: /usr/share/l.v.e-manager/utils/__pycache__/cpanel_api.cpython-311.pyc

�

�TiV5������ddlmZddlmZddlmZmZddlZddlmZddl	m
Z
mZddlZdZ
dZd	gZd
�ZGd�de��ZGd
�de��ZGd�de��ZdS)�)�absolute_import)�print_function)�exit_with_error�run_commandN)�abstractmethod)�
WhmApiRequest�WhmApiError�admin�userzIThe event UAPI::LangPHP::php_set_vhost_versions was handled successfully.c�P�|tkrt��St��S)z�
    Factory method that returns
    certain class depending on
    owner's type
    :param owner: Can be 'admin' or 'user'
    :return:
    )�OWNER_ADMIN�CPanelAdminApi�
CPanelUserApi)�owners �p/builddir/build/BUILDROOT/lvemanager-7.11.29-1.el9.cloudlinux.x86_64/usr/share/l.v.e-manager/utils/cpanel_api.py�get_cpanel_api_classrs%��
���������?�?��c��eZdZdZdZiZed���Zed���Zed���Z	e
d���Zd�Ze
d���Z
d	�Ze
d
���Zdd�Zd
S)�	CPanelApiz�
    Abstract method that defines abstract methods
    that must be implemented and common methods of
    the derived classes
    z
--output=jsonc� �td���)zo
        Checks whether operation is allowed to perform
        :param called_method:
        :return:
        z3Method check_operation_allowed must be implemented!��NotImplementedError��self�
called_methods  r�check_operation_allowedz!CPanelApi.check_operation_allowed+s��"�"W�X�X�Xrc� �td���)z^
        Depending on the passed arguments,
        the method builds running command
        z3Method prepare_running_command must be implemented!r)rr�params�return_jsons    r�prepare_running_commandz!CPanelApi.prepare_running_command4s��"�"W�X�X�Xrc� �td���)z�
        Some results are parsed before sending back
        to the called. This method parses it and returns
        transformed result.
        z(Method parse_result must be implemented!r)rr�results   r�parse_resultzCPanelApi.parse_result<s��"�"L�M�M�Mrc�.�|D]}||dkrdS�dS)zo
        CPanel API contains several methods and
        not all of them if supported by this utility.
        �methodTF���method_name�methods�
method_objects   r�check_method_allowedzCPanelApi.check_method_allowedEs4��%�	�	�M��m�H�5�5�5��t�t�6��urc� �td���)zq
        Checks whether CPanel API returned
        error or not
        :param result:
        :return:
        z,Method check_for_errors must be implemented!r)rr"s  r�check_for_errorszCPanelApi.check_for_errorsPs��"�"P�Q�Q�Qrc�X�|D]&}||dkr|�dd��cS�'dS)z�
        Some result must be parsed before
        they are sent back to the caller. This
        method extracts the method that must be executed
        upon the result to transform it.
        r%�parserN��getr's   r�get_method_parserzCPanelApi.get_method_parserYsN��%�	9�	9�M��m�H�5�5�5�$�(�(��4�8�8�8�8�8�6�	9�	9rc�X�|D]&}||dkr|�dd��cS�'dS)zF
        return ignore error flag for method
        :return:
        r%�
ignore_errorsNr0)rr(r)r*s    r�get_ignore_errorszCPanelApi.get_ignore_errorsesR��
%�	@�	@�M��m�H�5�5�5�$�(�(��$�?�?�?�?�?�6�	@�	@rc
� �g}|D]�}|�|�d��|�d��|�d��rdnd|�di���d��dkrdndd	�����|S)
z�
        Method parses the result of the method 'parse_vhost_versions'.
        The host will be inherited when its field 'sys_default'
        inside 'php_version_source' is equal to 1.
        �version�vhost�php_fpmTF�php_version_source�sys_default�)r7�hostr9�	inherited��appendr1�r"�
parsed_result�rs   r�parse_vhost_versionszCPanelApi.parse_vhost_versionsns����
��	�	�A�� � ��5�5��+�+����g���#$�5�5��#3�#3�>�4�4��%&�U�U�+?��%D�%D�%H�%H��%W�%W�[\�%\�%\�T�T�bg�	"�"�
�
�
�
��rTc��|�|��r�|�|||��}t|d���\}}}|dkrt|pd|�d|����	t	j|��}|�||��S#t$r}	t|	��Yd}	~	dSd}	~	wwxYwtd�|����dS)z�
        Default method which first checks whether operation
        is allowed then if allowed runs prepared command.
        After receiving the result, it will call parse_result method
        to transform result into desired format.
        T)�return_full_outputrzoutput of the command: �
N�Not allowed operation: {})	rr rr�json�loadsr#�
ValueError�format)
rrrr�prepared_command�code�output�std_errr"�es
          r�runz
CPanelApi.runs���'�'�
�6�6�
	O�#�;�;�M�6�S^�_�_��$/�0@�UY�$Z�$Z�$Z�!�D�&�'��q�y�y��� g� g�N^�N^�N^�`f�`f�+g�h�h�h�
#���F�+�+���(�(���?�?�?���
#�
#�
#���"�"�"�"�"�"�"�"�"�����
#����
�7�>�>�}�M�M�N�N�N�N�Ns� )B
�

B.�B)�)B.N�T)�__name__�
__module__�__qualname__�__doc__�RETURN_JSON�ALLOWED_OPERATIONSrrr r#�staticmethodr+r-r2r5rDrRr&rrrr!s��������"�K����Y�Y��^�Y��Y�Y��^�Y��N�N��^�N�����\��R�R�R��	9�	9��\�	9�@�@�@�����\�� O�O�O�O�O�Orrc�b�eZdZdZdd�d�ddiddiddigZd	�Zd
�Zd�Zed���Z	dd�Z
dS)rz/usr/local/cpanel/bin/whmapi1�php_get_vhost_versionsc�6�t�|��S�N)rrD�r"s r�<lambda>zCPanelAdminApi.<lambda>�s��^�%H�%H��%P�%P�r)r%r/r%�php_get_system_default_version�php_set_vhost_versions�php_get_installed_versionsc�8�|�||j��Sr^)r+rYrs  rrz&CPanelAdminApi.check_operation_allowed�s���(�(���8O�P�P�Prc�N�i}|D]}|�d��\}}|||<� |S)N�=)�split)rrrr�transformed_params�param�key�values        rr z&CPanelAdminApi.prepare_running_command�s@�����	,�	,�E����S�)�)�J�C��&+��s�#�#�!�!rc�V�|�||j��}|�||��S|Sr^)r2rY)rrr"r/s    rr#zCPanelAdminApi.parse_result�s3���'�'�
�t�7N�O�O�����6�&�>�>�!��
rc�T�g}|dD]�}|�|�d��|�d��|�d��|�d��rdnd|�di���d	��d
krdndd�����|S)N�versionsr7r8�accountr9TFr:r;r<)r7r=rr9r>r?rAs   rrDz#CPanelAdminApi.parse_vhost_versions�s����
��
�#�	�	�A�� � ��5�5��+�+����g������i�(�(�#$�5�5��#3�#3�>�4�4��%&�U�U�+?��%D�%D�%H�%H��%W�%W�[\�%\�%\�T�T�bg�"�"�
�
�
�
��rTc��|�|||��}|�|��r|	|�|t|��jdi|�������S#t$r.}t|��tj	d��Yd}~dSd}~wwxYwtd�|����dS)Nr<rHr&)r rr#r�with_arguments�callr	�print�sys�exitrrL)rrrrrQs     rrRzCPanelAdminApi.run�s����-�-�m�V�[�Q�Q���'�'�
�6�6�	O�
��(�(��8c�
�m�8T�8T�8c�8m�8m�fl�8m�8m�8r�8r�8t�8t�u�u�u���
�
�
��a��������������������
����
�7�>�>�}�M�M�N�N�N�N�Ns�?A.�.
B&�8#B!�!B&NrS)rTrUrV�COMMANDrYrr r#rZrDrRr&rrrr�s�������-�G�/�P�P�	
�	
�
�3�4�	�+�,�	�/�0���Q�Q�Q�"�"�"�����
�
��\�
�	O�	O�	O�	O�	O�	Orrc�r�eZdZdZdddiddd�dd	�dd
�ddd�giZd�Zd
�Zed���Zd�Z	d�Z
dd�ZdS)rz
/usr/bin/uapi�LangPHPr%rbrcT)r%r4r\c�6�t�|��Sr^)rrDr_s rr`zCPanelUserApi.<lambda>�s���)G�)G��)O�)O�r)r%r/r4rac�8�||j���vS)zx
        CPanel UAPI requires to pass class name and
        only few of classes are supported by this utility.
        )rY�keys)r�
class_names  r�check_class_allowedz!CPanelUserApi.check_class_allowed�s��
�T�4�9�9�;�;�;�;rc��|�|��\}}|�|��r!|�||j|��SdS)z�
        Checks whether operation is allowed or not.
        By CPanel UAPI supports several operations
        but only few of them can be called via this utility.
        F)�extract_class_and_methodr}r+rY)rrr|r(s    rrz%CPanelUserApi.check_operation_allowed�sW��#'�"?�"?�
�"N�"N��
�K��#�#�J�/�/�	_��,�,�[�$�:Q�R\�:]�^�^�^��urc��	|�d��\}}||fS#t$r&td�|����YdSwxYw)Nz::zInvalid method is passed: {})rgrKrrL)rr|r(s   rrz&CPanelUserApi.extract_class_and_method�sp��	R�&3�&9�&9�$�&?�&?�#�J���{�*�*���	R�	R�	R��:�A�A�-�P�P�Q�Q�Q�Q�Q�Q�	R���s��,A�
Ac��|�|��\}}|j||g|z}|r|�|j��|Sr^)rrvr@rX)rrrrr|r(s      rr z%CPanelUserApi.prepare_running_command�sO��"&�"?�"?�
�"N�"N��
�K��,�
�K�8�6�A���	,��M�M�$�*�+�+�+��
rc�0�|�|��\}}|�||j|��}|�||��|�||j|��}|�||dd��S|ddS)Nr"�data)rr5rYr-r2)rrr"r|r(r4r/s       rr#zCPanelUserApi.parse_results���"&�"?�"?�
�"N�"N��
�K��.�.�{�D�<S�T^�<_�`�`�
����f�m�4�4�4��'�'��T�5L�Z�5X�Y�Y�����6�&��*�6�2�3�3�3��h���'�'rFc��|d�d��}|sdS|D]0}|tvr�td�|��|����1dS)Nr"�errors� )r4)r1�UAPI_IGNORED_ERRORSr�join)rr"r4r��errors     rr-zCPanelUserApi.check_for_errors
sw����!�%�%�h�/�/���	��F��	K�	K�E��+�+�+���C�H�H�V�,�,�M�J�J�J�J�J�	K�	KrN)F)rTrUrVrvrYr}rrZrr r#r-r&rrrr�s��������G��
�/�0�6�!%�
�
�
3�O�O�!%�
�
�;�!%�
�
�
���&<�<�<�	�	�	��R�R��\�R����(�(�(�	K�	K�	K�	K�	K�	Krr)�
__future__rr�lvemanager.helpersrrrI�abcr�clcommon.lib.whmapi_librr	rtr
�
OWNER_USERr�r�objectrrrr&rr�<module>r�sW��'�&�&�&�&�&�%�%�%�%�%�%�;�;�;�;�;�;�;�;�����������>�>�>�>�>�>�>�>�
�
�
�
���
�
�b�c��
�
�
�rO�rO�rO�rO�rO��rO�rO�rO�j2O�2O�2O�2O�2O�Y�2O�2O�2O�jHK�HK�HK�HK�HK�I�HK�HK�HK�HK�HKr
Back to Directory  nL+D550H?Mx ,D"v]qv;6*Zqn)ZP0!1 A "#a$2Qr D8 a Ri[f\mIykIw0cuFcRı?lO7к_f˓[C$殷WF<_W ԣsKcëIzyQy/_LKℂ;C",pFA:/]=H  ~,ls/9ć:[=/#f;)x{ٛEQ )~ =𘙲r*2~ a _V=' kumFD}KYYC)({ *g&f`툪ry`=^cJ.I](*`wq1dđ#̩͑0;H]u搂@:~וKL Nsh}OIR*8:2 !lDJVo(3=M(zȰ+i*NAr6KnSl)!JJӁ* %݉?|D}d5:eP0R;{$X'xF@.ÊB {,WJuQɲRI;9QE琯62fT.DUJ;*cP A\ILNj!J۱+O\͔]ޒS߼J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