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

�Ҝpc�If�@s�ddlmZddlZddlmZmZddlmZddlm	Z	ddl
mZmZddl
mZddlmZdd	lmZdd
lmZmZddlmZGd
d�de�ZdS)�)�absolute_importN)�Dict�List)�Feature)�
MySQLGovernor)�ExternalProgramFailed�run_command)�	MysqlInfo)�	getCPName)�MODULES_LOGS_DIR)�InstallationFailedException�UserInterventionNeededError�)�WizardInstallercs�eZdZej�ed�ZdZdZ	e
jZ�fdd�Z
dd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Z�ZS)�GovernorInstallerzgovernor.log�unknownz*/usr/share/lve/dbgovernor/mysqlgovernor.pycstt|���t���|_dS)N)�superr�__init__r	�get�db_info)�self)�	__class__��py/clwizard/modules/governor.pyrszGovernorInstaller.__init__c
Csv|�d�sfy|�d�}Wn<tk
rT}z|j�dt|��t�|�Wdd}~XYnX|j�d|�n|j�d�dS)Nzgovernor-mysqlz*Package installation failed with error: %sz&Package was installed successfully: %sz=Skip the governor-mysql installation, it is already installed)Z_is_package_installedZ_install_packager�
app_logger�error�strr�info)r�out�errrrr�_install_governor_package*s
z+GovernorInstaller._install_governor_packagecCs||jdtjks |jdtjkr$dSy>|jd��}d�|jd�d�d�d�dd��}||Stk
rvdSXdS)N�vendor�version��-r�.�)rr�UNKNOWN�lower�join�split�
IndexError)rr!r"rrr�_prepare_db_options5s(z%GovernorInstaller._prepare_db_optionsc
CsVy&|j�d�|jtjddgdd�Wn*tk
rP}zt�|�Wdd}~XYnXdS)z�
        Trying to install governor with --wizard key, it detects the DB
        automatically (on DA and cPanel), for other panels we will have blockers
        for the governor module.
        zInstall MySQL Governorz	--installz--wizard�)�exit_statusN)rr�!_run_cmd_and_check_special_statusr�UTILITY_PATHrr)rrrrr�_initialize_governorDsz&GovernorInstaller._initialize_governorcCs`t|dd�\}}}||kr<|j�d�|j�d|�t��n |dkr\|j�d||�t|��dS)z�
        There are cases when some commands can't be executed without the user's
        intervention. Such scripts/commands return a special exit code that must
        be checked for.
        T)Zreturn_full_outputz$Can`t install governor automaticallyz
Reason: %srz2Error occurred during running "%s"
Reason is: "%s"N)rrZwarningr
rr)r�cmdr.Zretcoder�_rrrr/Tsz3GovernorInstaller._run_cmd_and_check_special_statuscCs*|jddkrtd��|��|��dS)Nr!z%Please, install a MySQL server first.)rrr r1)rZoptionsrrr�run_installationcsz"GovernorInstaller.run_installationcCs0ddig}|jddkr,|�dddid��|S)	zh
        Get list of warnings that should be shown in wizard
        before module installation
        �messagez�Please create a full database backup (including system tables). MySQL/MariaDB/Percona server will be updated from CloudLinux repositories.r!NzUCould not detect a MySQL server. For a list of compatible options please see %(url)s.�urlz<https://docs.cloudlinux.com/mysql_governor_installation.html)r5�context)r�append)r�warningsrrr�
_get_warningsiszGovernorInstaller._get_warningscCs&g}t�dkr"|�dddid��|S)zZ
        Get a list of possible blockers to disable Governor module in Wizard UI.
        )ZcPanelZDirectAdminzMySQL Governor can't be automatically installed. Please install it through the command-line interface. Learn more here: %(url)sr6z4https://docs.cloudlinux.com/installation-wizard.html)r5r7)r
r8)r�blockersrrr�
_get_blockers�s
zGovernorInstaller._get_blockerscCst�}|��o|jdS)z:
        Check if the governor is ready for work.
        zcll-lve)rZis_governor_presentr)rZ	mysql_govrrr�_is_already_configured�sz(GovernorInstaller._is_already_configuredcCsL|��|jdd�}|��}|r.|�d|i�|��}|rH|�d|i�|S)Nr")Zalready_configuredZ
db_versionr9r;)r=rr:�updater<)r�resultr9r;rrr�initial_status�sz GovernorInstaller.initial_status)�__name__�
__module__�__qualname__�os�pathr)rZLOG_FILEr'r0rZGOVERNORZ_REQUIRED_CL_COMPONENT_SUPPORTrr r,r1r/r4r:r<r=r@�
__classcell__rr)rrrsr)Z
__future__rrD�typingrrZclcommon.constrZclcommon.lib.mysql_governor_librZclcommon.utilsrrZclconfig.db_info_libr	Zcldetectlibr
Zclwizard.constantsrZclwizard.exceptionsrr
�baserrrrrr�<module>	s