Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/clwizard/modules/__pycache__/php.cpython-311.pyc
�

C(pe����ddlmZddlZddlmZmZmZddlmZm	Z	ddl
mZddlm
Z
mZddlmZdd	lmZdd
lmZGd�de��ZdS)
�)�absolute_importN)�List�Dict�Tuple)�MODULES_LOGS_DIR�CL_SELECTOR_BIN�)�WizardInstaller)�InstallationFailedException�PackageMissingError)�ExternalProgramFailed)�check_cagefs_initialized)�Featurec���eZdZej�ed��Zej	Z
d�Zd�Zd�Z
d�Zed���Zed���Zed���Zd	�Zd
�Zd�Zd�Zd
S)�PhpInstallerzphp.logc	��|j�d|��	|�tdddd|dg��dS#t$rt���wxYw)Nz)trying to set default php version as '%s'�set�
--interpreter�phpz--default-version�--json��
app_logger�info�_run_commandrr
r)�self�versions  �K/opt/cloudlinux/venv/lib64/python3.11/site-packages/clwizard/modules/php.py�_set_default_php_versionz%PhpInstaller._set_default_php_versions�������H�'�R�R�R�	0��������#�W�h�8�
9�
9�
9�
9�
9��%�	0�	0�	0�-�/�/�/�	0�����!A�Ac	��|j�d|��	|�tdddd|dg��dS#t$rt���wxYw)Nz%trying to set PHP Selector state '%s'rrrz--selector-statusrr)r�statuss  r�_set_cloudlinux_selector_statusz,PhpInstaller._set_cloudlinux_selector_status's�������D�f�M�M�M�	0��������#�V�X�7�
8�
8�
8�
8�
8��%�	0�	0�	0�-�/�/�/�	0���rc��|j�dd�|����g}|D]0}d|�dd��z}|�|���1	|j|�dS#t$rt���wxYw)z�
        Install given php versions via groups
        :param versions: e.g ['4.4', '5.4', '5.6']
        :return: None
        z)php version '%s' is going to be installed�,zalt-php�.�N)rr�join�replace�append�_install_groupsr
r)r�versions�groups�v�package_names     r�_install_php_versionz!PhpInstaller._install_php_version1s���	
����H�#�(�(�S[�J\�J\�]�]�]����	(�	(�A�$�q�y�y��b�'9�'9�9�L��M�M�,�'�'�'�'�		0�
!�D� �&�)�)�)�)��$�	0�	0�	0�-�/�/�/�	0���s�%
A1�1B
c�F�|�d��}|�dg��}|�d��}|r/|r-||vr)|j�d|��t���|�|��t��r�|r1|�d���|r|�|��d	Sd	S	|�d���d	S#t$r3}|j�dt|����Yd	}~d	Sd	}~wwxYwd	S)
a�
        Run installation of php module
        It is possible to install only alt-php packages and skip further
        installation if 'enable_selector': False
        Otherwise we will configure php selector also
        -- set selector status to enabled
        -- set default version if it was passed
        :param options: {'versions': [5.5, 5.6], 'enable_selector': True}
        :return:
        �default_versionr+�enable_selectorzSVersion %s that specified to be set as default must be included in install_versions�enabled)r!�disabledz/Error occurred while disabling PHP Selector: %sN)
�getr�errorrr/rr"r�	Exception�str)r�optionsr1�install_versions�to_enable_selector�es      r�run_installationzPhpInstaller.run_installationIs���"�+�+�&7�8�8��"�;�;�z�2�6�6��$�[�[�):�;�;���	4��
4�?�:J�#J�#J���%�%�;�<K�M�M�M�2�3�3�3��!�!�"2�3�3�3�#�%�%�
	e�!�	
e��4�4�I�4�F�F�F�"�C��1�1�/�B�B�B�B�B�C�C�e��8�8�
�8�K�K�K�K�K�� �e�e�e��O�)�)�*[�]`�ab�]c�]c�d�d�d�d�d�d�d�d�d�����e����
	e�
	es�	C!�!
D�+(D�Dc�
�hd�S)N>r+r1r2�)�clss r�supported_optionszPhpInstaller.supported_optionsns��A�A�A�A�c��	ddlm}n#t$rtd���wxYw|�����dS)Nr��ClSelect�
lvemanager)�clselect.clselectrE�ImportErrorr�get_versionrDs r�_php_get_default_versionz%PhpInstaller._php_get_default_versionrsb��	4�2�2�2�2�2�2�2���	4�	4�	4�%�l�3�3�3�	4�����x�z�z�%�%�'�'��*�*��	�#c�b�	ddlm}n#t$rtd���wxYw|d��S)Nr��"interpreter_versions_short_summaryrFr)�clselect.clselectctlrNrHrrMs r�_php_interpreters_listz#PhpInstaller._php_interpreters_list{sV��	4�O�O�O�O�O�O�O���	4�	4�	4�%�l�3�3�3�	4����1�1�%�8�8�8rKc��dddid�g}|S)zh
        Get list of warnings that should be shown in wizard
        before module installation
        z�Further CloudLinux PHP Selector setup will be available in LVE Manager settings after installation. More details you can find in our documentation %(url)s.�urlz:https://docs.cloudlinux.com/php_selector_installation.html)�message�contextr?)r�warningss  r�
_get_warningszPhpInstaller._get_warnings�s+��@��[�\�
�
����rBc�:�g}|���D]$}|js�
|�|j���%t	|��|���||�d��|���d�|���d�S)Nr)r1�installed_versions�available_versionsr2)�already_configuredr9rU)	rP�	installedr)r�anyrJ�_get_available_versions�_is_php_selector_enabledrV)rrX�its   r�initial_statuszPhpInstaller.initial_status�s��� ���-�-�/�/�	2�	2�B��<�
���%�%�b�j�1�1�1�1�#&�&8�"9�"9�#'�#@�#@�#B�#B�&8�&*�&B�&B�5�&I�&I�#'�#@�#@�#B�#B�	���*�*�,�,�
�
�	
rBc�`�tt��o|�����S)zM
        Return True if Php Selector enabled in UI and could be used
        )�boolr�"_is_php_selector_enabled_in_config)rs rr^z%PhpInstaller._is_php_selector_enabled�s7��
�,�.�.�B��?�?�A�A�C�C�	CrBc��|j�d��	ddlm}|d�����S#t
$rYdSwxYw)zn
        Return True if Php Selector is enabled for UI in panel specific (DA, Plesk or cPanel) config
        z!trying to get Php Selector state.r)�CloudlinuxSelectorLibrF)rr�clselector.selectorlibre�php_selector_is_enabledrH)rres  rrcz/PhpInstaller._is_php_selector_enabled_in_config�sq��
	
����@�A�A�A�	�D�D�D�D�D�D�(�(��/�/�G�G�I�I�I���	�	�	��5�5�	���s�"?�
A
�A
N)�__name__�
__module__�__qualname__�os�pathr'r�LOG_FILEr�PHP_SELECTOR�_REQUIRED_CL_COMPONENT_SUPPORTrr"r/r=�classmethodrA�staticmethodrJrPrVr`r^rcr?rBrrrs�������w�|�|�,�i�8�8�H�%,�%9�"�0�0�0�0�0�0�0�0�0�0#e�#e�#e�J�B�B��[�B��+�+��\�+��9�9��\�9����$
�
�
�*C�C�C�
�
�
�
�
rBr)�
__future__rrk�typingrrr�clwizard.constantsrr�baser
�clwizard.exceptionsrr�clcommon.utilsr
�!clconfig.cagefs_statistics_configr�clcommon.constrrr?rBr�<module>rzs��'�&�&�&�&�&�	�	�	�	�$�$�$�$�$�$�$�$�$�$�@�@�@�@�@�@�@�@�������Q�P�P�P�P�P�P�P�0�0�0�0�0�0�F�F�F�F�F�F�"�"�"�"�"�"�e�e�e�e�e�?�e�e�e�e�erB