Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/clwizard/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/clwizard/__pycache__/wizard.cpython-311.pyc

�

��f�9��>�ddlmZddlmZddlZddlZddlZddlZddlZddlm	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.Gd�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���eZdZdZejejejgZej	ejej
gZd�Zd�Z
ed���Zd�Zdd�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zedd���ZdS)�CloudlinuxWizardzAMain class for working with Wizard that exposes high level logic.c�n�d|_t��|_tdt��|_dS)Nzwizard.main)�_optsr�_supported_modulesr r�log��selfs �F/opt/cloudlinux/venv/lib64/python3.11/site-packages/clwizard/wizard.py�__init__zCloudlinuxWizard.__init__Cs,����
�"7�"9�"9����
�}�=�=�����c���t|��|_	|jjdkr�|���|���r#|jjs|�dd���|���|jjrt��n�|�
|jj���n�|jjdkrJ|���|jjr|�
��nq|���n\|jjdkr |�|jj��n,|jjdkr|���nt$�|jjd	vr|���s$|jjdkr<|���s(|���|���|���dS#t,$r[}|j�d
t3|����|�|j|j|jd���Yd}~dSd}~wt:$r|�d
d���YdSt<$r[}|j�dt3|����|�dtAj!�����Yd}~dSd}~wwxYw)zv
        CL Wizard main function
        :param argv: command line arguments for wizard
        :return: None
        �installzInstallation already finishedr��result�	exit_code)�options�status�cancel�finish)r-r3z;Got an error while running cloudlinux-wizard, message: '%s')r/�context�detailsr0Nz<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/r6)"rr$�	subparser�_validate_system�is_installation_finished�force�_print_result_and_exit�_prepare_for_installation�no_asyncr�run_background_installation�	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_updater	r&�error�str�messager5r6r�	Exception�	exception�	traceback�
format_exc)r(�argv�errs   r)�runzCloudlinuxWizard.runHs^��2�$�7�7��
�>	��z�#�y�0�0��%�%�'�'�'��0�0�2�2��4�:�;K���/�/�>�!�0�����.�.�0�0�0��:�&�S�$�&�&�&�&��4�4�T�Z�=Q�4�R�R�R�R���%��1�1��%�%�'�'�'��:�%�1��,�,�.�.�.�.��.�.�0�0�0�0���%��1�1��0�0���1B�C�C�C�C���%��1�1��-�-�/�/�/�/�)�)��
�$�(=�=�=��1�1�3�3�>��
�$��0�0��9V�9V�9X�9X�0��.�.�0�0�0��,�,�.�.�.��'�'�)�)�)�)�)��!�	�	�	��H�N�N�M�s�SV�x�x�
�
�
�
�'�'��{�C�K���XY�
(�
�
�
�
�
�
�
�
�
�����+�	�	�	��'�'�U��
(�
�
�
�
�
�
��	�	�	��H���G��S���R�R�R��'�'�@�!�,�.�.�
(�
�
�
�
�
�
�
�
�
�����	���s,�G#G;�;
K&�AI�$K&�	K&�AK!�!K&c�J�tj�t��S�N)�os�path�isfiler�r+r)r9z)CloudlinuxWizard.is_installation_finished�s���w�~�~�.�/�/�/r+c�*�	tjt��|j�d��dS#t
tf$rJ}|j�dt|����|�	dd���Yd}~dSd}~wwxYw)NzWizard execution completez:Wizard 'finish' command called more than once, error: '%s'z-Wizard 'finish' command called more than oncerr.)
rV�mknodrr&�info�OSError�IOError�warningrKr;)r(rRs  r)rEz)CloudlinuxWizard.create_completion_marker�s���		��H�%�&�&�&��H�M�M�5�6�6�6�6�6����!�	�	�	��H���L�c�RU�h�h�
�
�
�
�'�'�F�RS�
(�
�
�
�
�
�
�
�
�
�����		���s�37�B�?B
�
BNc��tjdd�}|�d��t��5}t	��r|�dd���|�|�|��t|��j}||_	ddd��n#1swxYwY|�d|���dS)Nz
--no-asynczMUnable to start a new installation because a background task is still workingrr.�success)r/�pid)
�sysrQ�appendrrr;�set_modulesrrb�
worker_pid)r(r1�cmd�configrfs     r)r>z,CloudlinuxWizard.run_background_installation�s
���h�q�q�q�k���
�
�<� � � �
"�
$�
$�	+��-�.�.�
��+�+�9��,�����"��"�"�7�+�+�+�(��,�,�0�J� *�F��	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+� 	
�#�#�9�*�#�E�E�E�E�Es�AB�B �#B c�R�t���|�d���dSdS)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/)rr;r's r)r8z!CloudlinuxWizard._validate_system�sD�����#��'�'�.�
(�
�
�
�
�
�$�#r+c��t��rfgd�}	t|��}|j�d|��dS#t$r(}|j�d||���Yd}~dSd}~wwxYwgd�}	t|��}|j�d|��dS#t$r(}|j�d||���Yd}~dSd}~wwxYw)	z�
        Prepare the enviroment before performing the installation.
        This function updates the package lists if run on Ubuntu, expires Yum
        cache when running on RHEL-based systems.
        )zapt-getz-q�updatezapt-get update output:
%sz!Error during apt-get update: '%s')�exc_infoN)�yumz-qy�cleanzexpire-cachez!yum clean expire-cache output:
%sz)Error during yum clean expire-cache: '%s')rr
r&r\rrJ�r(rg�outrRs    r)r<z*CloudlinuxWizard._prepare_for_installation�s+���;�;�
	_�-�-�-�C�
W�!�#�&�&����
�
�:�C�@�@�@�@�@��(�
W�
W�
W�����B�C�RU��V�V�V�V�V�V�V�V�V�����
W����:�9�9�C�
_�!�#�&�&����
�
�B�C�H�H�H�H�H��(�
_�
_�
_�����J�C�Z]��^�^�^�^�^�^�^�^�^�����
_���s/�*A�
A2�
A-�-A2�:*B&�&
C�0C�Cc�&�|j|jS)zGet path to module log file)r%�LOG_FILE)r(�module_names  r)�_get_module_log_pathz%CloudlinuxWizard._get_module_log_path�s���&�{�3�<�<r+c�0�g}t��5}|�|��}|jD]�}	|�|��}|�|��}n#t
$rY�:wxYw|||d�}|tjtjfvr|�	|��|d<|�
|����	ddd��n#1swxYwY|tjkr|�
||t���|�
||���dS)z?
        Get information about background worker state
        )r2�name�status_time�log_fileN)�
wizard_status�modules�	crash_log)rzr{)r�_get_wizard_stater%�get_module_status�get_module_status_timerr�FAILED�AUTO_SKIPPEDrurdr�CRASHEDr;r)r(r{rh�staterwr2rx�
module_statuss        r)rBz&CloudlinuxWizard._get_modules_statuses�s�����
"�
$�
$�	.���*�*�6�2�2�E��/�

.�

.���#�5�5�d�;�;�F�"(�"?�"?��"E�"E�K�K��#�����H�����%� �#.�!�!�
�
�l�1�<�3L�M�M�M�04�0I�0I�$�0O�0O�M�*�-����}�-�-�-�-�

.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.�	.����	.�	.�	.�	.� �L�(�(�(��'�'�#�W��
(�
�
�
�	
�#�#�%��#�I�I�I�I�Is5�C�*A�C�
A)�&C�(A)�)AC�C�Cc	�.�t��}|r|�|���dS|�d�|j���D��t	tt��t|j��z
�����dS)zg
        Get initial modules status that is used
        by lvemanager to display wizard pages
        rjc�N�i|]"\}}||�������#SrY)�initial_status)�.0rt�clss   r)�
<dictcomp>z8CloudlinuxWizard._get_initial_status.<locals>.<dictcomp>s@�����(��S� �����!5�!5�!7�!7���r+)r{�unsuppored_by_cpN)r
r;r%�items�list�setr)r(�
error_messages  r)rAz$CloudlinuxWizard._get_initial_status�s���
.�/�/�
��
	��'�'�}�'�=�=�=�=�=��'�'���,0�,C�,I�,I�,K�,K����"&�c�+�&6�&6��T�=T�9U�9U�&U�!V�!V�
(�
�
�
�
�
r+c��|j�d|��t��5}|�|��}||jvr=|�|tj���|j�d|��n,|j�d||��t||���	ddd��dS#1swxYwYdS)z@Remove module from queue or print the error if it's not possiblez0Trying to cancel the installation of module '%s')rt�	new_statez.Module '%s' installation successfully canceledzGUnable to cancel module '%s' installation, because it is in status '%s'N)
r&r\rr~�CANCELLABLE_MODULE_STATUSES�set_module_statusr�	CANCELLEDr_r)r(rDrhr2s    r)rCz,CloudlinuxWizard._cancel_module_installations(��	
��
�
�H�&�Q�Q�Q�
"�
$�
$�	<���-�-�f�5�5�F���9�9�9��(�(� &�,�2H�)������
�
�N�PV�W�W�W�W��� � �3���	���,�F�F�;�;�;�X�
	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<�	<����	<�	<�	<�	<�	<�	<s�BC�C�Cc�f�ddg}tj�d��s|�d��|j�d��	t
|��}|j�d|��dS#t$r&}|j�d|��Yd}~dSd}~wwxYw)	z,
        Collects user`s statistics
        z/usr/sbin/cloudlinux-summaryz--send�SYNCHRONOUS_SUMMARYz--asynczCollecting statistics...z*Statistics collection command output: '%s'z(Error during statistics collection: '%s'N)	rV�environ�getrdr&r\r
rrJrps    r)rHz*CloudlinuxWizard.run_collecting_statisticss���.�x�8���z�~�~�3�4�4�	"��J�J�y�!�!�!���
�
�0�1�1�1�	L��c�"�"�C��H�M�M�F��L�L�L�L�L��$�	L�	L�	L��H�N�N�E�s�K�K�K�K�K�K�K�K�K�����	L���s�*B�
B0�
B+�+B0c����t��5}t|j�����}ddd��n#1swxYwYt	�fd�|D����S)zy
        Check that all modules were either:
        -- installed
        -- canceled
        -- or auto-skipped
        Nc3�*�K�|]
}|�jvV��dSrU��DONE_MODULES_STATUSES�r�r2r(s  �r)�	<genexpr>z<CloudlinuxWizard.is_all_modules_installed.<locals>.<genexpr>8�+�����O�O�F�6�T�7�7�O�O�O�O�O�Or+)rr��statuses�values�all�r(rhr�s`  r)rGz)CloudlinuxWizard.is_all_modules_installed.s����#�
$�
$�	6���F�O�2�2�4�4�5�5�H�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6����	6�	6�	6�	6��O�O�O�O�h�O�O�O�O�O�Os�'A�A�
Ac�2�d}tj�|��sdS|ddg}|j�d|��t|��}t
tj�d����}|r|�	��dSdS)z=
        Runs cagefsctl --force-update in background
        z/usr/sbin/cagefsctlNz--force-updatez--wait-lockz2Starting cagefs force-update in the background: %s�CL_TEST_SYSTEM)
rVrWrXr&r\r�boolr�r��communicate)r(�
cagefsctl_binrg�cagefsctl_proc�is_test_environments     r)rIz(CloudlinuxWizard.run_cagefs_force_update:s���.�
��w�~�~�m�,�,�	��F��.�
�>����
�
�J�C�P�P�P�'��,�,��"�2�:�>�>�2B�#C�#C�D�D���	)��&�&�(�(�(�(�(�	)�	)r+c����|j�tjS	tj|j��tjS#tj$r�t|j�	����}t�fd�|D����rtjcYStd�|D����r'td�|D����stj
cYStjcYSwxYw)Nc3�*�K�|]
}|�jvV��dSrUr�r�s  �r)r�z5CloudlinuxWizard._get_wizard_state.<locals>.<genexpr>[r�r+c3�JK�|]}|tjtjfvV��dSrU)rr�r��r�r2s  r)r�z5CloudlinuxWizard._get_wizard_state.<locals>.<genexpr>_sF��������|�2�L�4J�K�K������r+c3�4K�|]}|tjfvV��dSrU)r�
INSTALLINGr�s  r)r�z5CloudlinuxWizard._get_wizard_state.<locals>.<genexpr>bs-����V�V�6�&�\�%<�$>�>�V�V�V�V�V�Vr+)rfr�IDLE�psutil�Process�IN_PROGRESS�
NoSuchProcessr�r�r�r��DONE�anyr�r�r�s`  r)r}z"CloudlinuxWizard._get_wizard_stateJs���
��$��$�$�	,��N�6�,�-�-�-�& �+�+��%�#�	(�	(�	(��F�O�2�2�4�4�5�5�H��O�O�O�O�h�O�O�O�O�O�
)�#�(�(�(�(����"*������
+��V�V�X�V�V�V�V�V�
+�$�*�*�*�*��'�'�'�'�!	(���s�;�AC(�>C(�C(�'C(rarc���|tj��d�}|�|��ttj|dd�����tj|��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/�	timestamp�T)�indent�	sort_keysN)�timerl�print�json�dumpsrc�exit)r/r0�extrarLs    r)r;z'CloudlinuxWizard._print_result_and_exiths^��$�$�)�+�+�>�>�����u����
�d�j���d�;�;�;�<�<�<��������r+rU)rar)�__name__�
__module__�__qualname__�__doc__r�PENDINGr�r�r��	INSTALLEDr�r�r*rS�staticmethodr9rEr>r8r<rurBrArCrHrGrIr}r;rYr+r)r"r"2sx������K�K�	������#��	�����!���>�>�>�
E�E�E�N�0�0��\�0����F�F�F�F�,	�	�	�_�_�_�,=�=�=�J�J�J�:���$<�<�<�(
L�
L�
L�
P�
P�
P�)�)�)� ,�,�,�<�
�
�
��\�
�
�
r+r")1�
__future__rrr�rVrcr�rO�typingrrrrr��clcommonr	�clcommon.utilsr
rrr
�clcommon.lib.cleditionr�clwizard.configrrhrrr{rrr�	constantsrrrrr�
exceptionsrr�parserr�utilsrrr �objectr"rYr+r)�<module>r�s)��&�%�%�%�%�%�&�&�&�&�&�&�����	�	�	�	�
�
�
�
���������0�0�0�0�0�0�0�0�0�0�0�0�
�
�
�
�'�'�'�'�'�'�����������
1�0�0�0�0�0�,�,�,�,�,�,�(�(�(�(�(�(�)�)�)�)�)�)�������I�I�I�I�I�I�I�I�I�I���������������K�J�J�J�J�J�J�J�0�0�0�0�0�0�����������A�A�A�A�A�v�A�A�A�A�Ar+

Hacked By AnonymousFox1.0, Coded By AnonymousFox