HEX
Server: Apache
System: Linux insrv.serversdaddy.com 5.14.0-362.24.2.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 30 14:11:54 EDT 2024 x86_64
User: jsaha (1066)
PHP: 8.3.6
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/clwizard/modules/__pycache__/php.cpython-37.pyc
B

pM�d�֘�@s�ddlmZddlZddlmZmZddlmZddlm	Z	ddl
mZddlm
Z
mZddlmZmZd	d
lmZGdd�de�ZdS)
�)�absolute_importN)�Dict�List)�Feature)�ExternalProgramFailed)�check_cagefs_initialized)�CL_SELECTOR_BIN�MODULES_LOGS_DIR)�InstallationFailedException�PackageMissingError�)�WizardInstallerc@s�eZdZej�ed�Zej	Z
dd�Zdd�Zdd�Z
dd	�Zed
d��Zedd
��Zedd��Zdd�Zdd�Zdd�Zdd�ZdS)�PhpInstallerzphp.logc
CsZ|j�d|�y|�tdddd|dg�Wn*tk
rT}zt�|�Wdd}~XYnXdS)Nz)trying to set default php version as '%s'�setz
--interpreter�phpz--default-versionz--json)�
app_logger�info�_run_commandrrr
)�self�version�e�r�py/clwizard/modules/php.py�_set_default_php_versionsz%PhpInstaller._set_default_php_versionc
CsZ|j�d|�y|�tdddd|dg�Wn*tk
rT}zt�|�Wdd}~XYnXdS)Nz%trying to set PHP Selector state '%s'rz
--interpreterrz--selector-statusz--json)rrrrrr
)r�statusrrrr�_set_cloudlinux_selector_status-sz,PhpInstaller._set_cloudlinux_selector_statusc
Cs~|j�dd�|��g}x&|D]}d|�dd�}|�|�qWy|j|�Wn*tk
rx}zt�|�Wdd}~XYnXdS)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�appendZ_install_groupsrr
)r�versions�groups�vZpackage_namerrrr�_install_php_version?s
z!PhpInstaller._install_php_versionc
Cs�|�d�}|�dg�}|�d�}|rD|rD||krD|j�d|�t��|�|�t�r�|rt|jdd�|r�|�|�nFy|jdd�Wn4tk
r�}z|j�dt	|��Wd	d	}~XYnXd	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_selectorzWVersion %s that was specified to be set as default must be included in install_versionsZenabled)rZdisabledz/Error occurred while disabling PHP Selector: %sN)
�getr�errorr
r%rrr�	Exception�str)r�optionsr&Zinstall_versionsZto_enable_selectorrrrr�run_installationYs(


zPhpInstaller.run_installationcCs
dddhS)Nr&r"r'r)�clsrrr�supported_options�szPhpInstaller.supported_optionsc
CsLyddlm}Wn,tk
r<}ztd�|�Wdd}~XYnX|���dS)Nr)�ClSelect�
lvemanager)Zclselect.clselectr0�ImportErrorrZget_version)r0rrrr�_php_get_default_version�s
z%PhpInstaller._php_get_default_versionc
CsFyddlm}Wn,tk
r<}ztd�|�Wdd}~XYnX|d�S)Nr)�"interpreter_versions_short_summaryr1r)Zclselect.clselectctlr4r2r)r4rrrr�_php_interpreters_list�s
z#PhpInstaller._php_interpreters_listcCsdddid�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. Find more details in our documentation at %(url)s.Zurlz:https://docs.cloudlinux.com/php_selector_installation.html)�message�contextr)r�warningsrrr�
_get_warnings�szPhpInstaller._get_warningscCsVg}x$|��D]}|jsq|�|j�qWt|�|��||�d�|��d�|��d�S)Nr)r&�installed_versionsZavailable_versionsr')Zalready_configuredr,r8)	r5Z	installedr!r�anyr3Z_get_available_versions�_is_php_selector_enabledr9)rr:�itrrr�initial_status�s
zPhpInstaller.initial_statuscCstt�o|���S)zM
        Return True if Php Selector enabled in UI and could be used
        )�boolr�"_is_php_selector_enabled_in_config)rrrrr<�sz%PhpInstaller._is_php_selector_enabledcCs>|j�d�yddlm}|d���Stk
r8dSXdS)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)�CloudlinuxSelectorLibrFN)rrZclselector.selectorlibrAZphp_selector_is_enabledr2)rrArrrr@�sz/PhpInstaller._is_php_selector_enabled_in_configN)�__name__�
__module__�__qualname__�os�pathrr	ZLOG_FILErZPHP_SELECTORZ_REQUIRED_CL_COMPONENT_SUPPORTrrr%r-�classmethodr/�staticmethodr3r5r9r>r<r@rrrrrs)		r)Z
__future__rrE�typingrrZclcommon.constrZclcommon.utilsrZ!clconfig.cagefs_statistics_configrZclwizard.constantsrr	Zclwizard.exceptionsr
r�baser
rrrrr�<module>	s