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__/ruby.cpython-37.pyc
B

�E0�����@s�ddlmZddlZddlmZddlmZmZmZddl	m
Z
ddlmZddl
mZddlmZd	d
lmZGdd�de�ZdS)
�)�absolute_importN)�Feature)�ExternalProgramFailed�get_passenger_package_name�is_litespeed_running)�
get_ui_config)�MODULES_LOGS_DIR)�InstallationFailedException)�installed_interpreters_list�)�WizardInstallercsdeZdZej�ed�Zej	Z
�fdd�Zdd�Zdd�Z
dd	�Zd
d�Zdd
�Zedd��Z�ZS)�
RubyInstallerzruby.logcstt|���dS)N)�superr
�__init__)�self)�	__class__��py/clwizard/modules/ruby.pyrszRubyInstaller.__init__c
Cs~g}x&|D]}d|�dd�}|�|�q
W|j�dd�|��y|j|�Wn*tk
rx}zt�|�Wdd}~XYnXdS)Nzalt-ruby�.�z-Try to install Ruby package with versions: %s�,)�replace�appendZ
app_logger�info�joinZ_install_groupsrr	)r�versions�groups�vZpackage_name�errr�_install_ruby_versionss
z$RubyInstaller._install_ruby_versionsc
CsVd}tj�|�sdSy|�d|g�Wn*tk
rP}zt�|�Wdd}~XYnXdS)a
        In order to make ruby apps work on Litespeed server, we need to run an
        extra script

        See docs for details:
        https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cloudlinux:enable_passenger
        :return:
        z9/usr/local/lsws/admin/misc/enable_ruby_python_selector.shNZsh)�os�path�isfile�_run_commandrr	)rZlitespeed_scriptrrrr�_configure_for_litespeed_server)s	z-RubyInstaller._configure_for_litespeed_servercCs2|�t��}t�p(t��di��d�}|o0|S)a�
        Check that the Ruby Selector is ready to work

        All configurations were done and Passenger is installed
        We always have at least one ruby package installed, because it's a
        dependency of the Passenger package, so we can skip that check
        If the config file does not exist, we ignore the uiSettings
        :return: already_configured status
        :rtype: bool
        Z
uiSettingsZhideRubyApp)Z_is_package_installedrr�get)rZpassenger_installedZ
configs_okrrr�_is_already_configured<sz$RubyInstaller._is_already_configuredcCsFg}td�}x|D]}|jr|�|j�qW|��||�d�d�d�S)NZruby)Zinstalled_versionsZavailable_versions)Zalready_configured�options)r
Z	installedr�versionr&Z_get_available_versions)rZinstalled_ruby_versionsZinterpreters_listZinterpreterrrr�initial_statusKs
zRubyInstaller.initial_statusc
Csr|�dg�}|��|�|�t�r,|��y|�ddddg�Wn*tk
rl}zt�|�Wdd}~XYnXdS)Nrzcloudlinux-config�setz--jsonz:--data={"options": {"uiSettings": {"hideRubyApp": false}}})r%Z_install_passengerrrr$r#rr	)rr'Zinstall_versionsrrrr�run_installationYs
zRubyInstaller.run_installationcCsdhS)Nrr)�clsrrr�supported_optionsmszRubyInstaller.supported_options)�__name__�
__module__�__qualname__r r!rrZLOG_FILErZ
RUBY_SELECTORZ_REQUIRED_CL_COMPONENT_SUPPORTrrr$r&r)r+�classmethodr-�
__classcell__rr)rrr
sr
)Z
__future__rr Zclcommon.constrZclcommon.utilsrrrZclconfig.ui_config_librZclwizard.constantsrZclwizard.exceptionsr	Zclwizard.utilsr
�baserr
rrrr�<module>	s