????

Your IP : 18.218.229.244


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

�

-ڠg{���R�dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZddlm
Z
mZmZmZmZddlmZddlmZddlmZmZmZmZmZmZmZmZmZm Z m!Z!dd	l"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(dd
l)m*Z*ddl+m,Z,ddl-m.Z.dd
l/m0Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7m8Z8ddl9m:Z:m;Z;m<Z<m=Z=ddl>m?Z?m@Z@ddlAmBZBmCZCddlDmEZEmFZFmGZGddlHmIZImJZJmKZKmLZLddlMmNZNddlOmPZPddlQmRZRmSZSddlTmUZUmVZVddlWmXZXddlYmZZZm[Z[dZ\Gd�d e��Z]eGd!�d"����Z^Gd#�d$��Z_dS)%zB
This module contains X Ray Smart Advice local utility main class
�N)�contextmanager)�asdict�	dataclass)�Any�Tuple�Optional�List�Dict)�Enum)�LicenseApproveStatus)�is_feature_allowed�is_subscription_pending�get_subscription_upgrade_url�get_license_approve_status�approve_license_agreement�get_license_agreement_text�get_subscriptions_info�get_user_auth_key�2is_smart_advice_notifications_disabled_server_wide�.is_smart_advice_reminders_disabled_server_wide�5is_smart_advice_wordpress_plugin_disabled_server_wide)�docroot�is_panel_feature_supported�get_user_emails_list�panel_awp_link�	getCPName�userdomains)�
is_wp_path)�drop_privileges)�Feature)�gettext�)�get_advice_instance)�SmartAdviceProgress�)�
get_client�
api_client)�advice_pending_storage�advice_processed_storage�advice_list_cache�advice_reason_max_len)�get_lve_limits�
get_lve_usage)�	XRayError�SmartAdvicePluginError)�user_mode_advice_verification�username_verification�get_xray_exec_user)�	timestamp�	safe_move�get_user_php_version�filelock)�report_usage_action_or_error)�ClWposGetter)�get_mu_directory�"create_mu_plugins_dir_if_not_exist)�plugin_installed�prepare_system_analytics_data)�report_analytics)�ImunifyManager�ADV_TYPE�;c��eZdZdZdZdS)�
AdviceActions�apply�rollbackN)�__name__�
__module__�__qualname__�APPLY�ROLLBACK���K/opt/cloudlinux/venv/lib64/python3.11/site-packages/xray/adviser/cli_api.pyrBrBKs�������E��H�H�HrKrBc�V�eZdZUeed<eed<eed<eed<eed<eed<eed<dS)	�SmartAdviceOptions�
panel_type�	panel_url�panel_emails�upgrade_url�upgrade_url_cdn�subscription�
notificationsN)rErFrG�str�__annotations__�dictrJrKrLrNrNPs`��������O�O�O��N�N�N����������������������rKrNc���eZdZdZd�Zededdfd���Zedefd���Zede	defd	���Z
de	deefd
�Zede	defd���Z
de	defd
�Zde	defd�Zd�Zede	deeeffd���ZedNdedededdfd���Zde	dedefd�Zde	dededeeeffd�ZdNdefd�Zedefd���ZdOd�Zd�Z d �Z!de	defd!�Z"				dPde	d#ed$ed%ed&ed'ed(edeefd)�Z#			dQd*ede	d#ed$ed%ed&ed'edeefd+�Z$defd,�Z%de	defd-�Z&d.�Z'd/�Z(d0�Z)e		dRd1���Z*ed2���Z+ed3���Z,ed4���Z-dSd6�Z.d7�Z/dTd8�Z0ed9efd:���Z1defd;�Z2ed<���Z3ed=���Z4de5eeffd>�Z6ed?���Z7d@�Z8dA�Z9dB�Z:dC�Z;dTdD�Z<	dUdFe=edGede=efdH�Z>edIedJe=ede=efdK���Z?dL�Z@dM�ZAdS)V�SmartAdviceUtilz%Main Smart Advice local utility classc���tjd��|_ttfD]}|�|���t
d��}|��|_t��|_	dS)N�smart_advice�adviser)
�logging�	getLogger�loggerr(r)�
create_dirr&�adviser_clientr>�imunify_manager)�self�stor�adviser_client_objects   rL�__init__zSmartAdviceUtil.__init__^sq���'��7�7���+�-E�F�	"�	"�D��O�O�D�!�!�!�!� *�9� 5� 5��?T�?T�?V�?V���-�/�/����rK�dpath�returnNc�p�tj�|��stj|��dSdS)zCreate dir if missingN)�os�path�isdir�mkdir)rhs rLrazSmartAdviceUtil.create_dirhs5���w�}�}�U�#�#�	��H�U�O�O�O�O�O�	�	rKc���dt��d�}|r|�|��tjt	t|���������S)z�
        Create JSON response message with result field == success
        and given keyword arguments in other fields
        :return: json packed string
        �success)�resultr3)r3�update�json�dumpsrX�sorted�items)�kwargs�initials  rL�responsezSmartAdviceUtil.responsensW��'�Y�[�[�A�A���	#��N�N�6�"�"�"��z�$�v�g�m�m�o�o�6�6�7�7�8�8�8rK�a_idc��t�d|��S)z%Per-advice file with results of apply�/)r)�rzs rL�_apply_datafilezSmartAdviceUtil._apply_datafilezs��+�3�3�T�3�3�3rKc��|�|��}tj�|��r�	t	|��5}tj|��}ddd��n#1swxYwYn]#t$rd}YnOt
j$r>t	|��5}|�	��}ddd��n#1swxYwYYnwxYwtj
|��n#tj
|��wxYw|SdS)z=Retrieve data stored in per-advice file with results of applyN)r~rkrl�isfile�openrs�load�OSError�JSONDecodeError�read�unlink)rdrz�datafile�_f�datas     rL�_apply_resultszSmartAdviceUtil._apply_resultss|���'�'��-�-��
�7�>�>�(�#�#�	�	
$��(�^�^�)�r��9�R�=�=�D�)�)�)�)�)�)�)�)�)�)�)����)�)�)�)����
�
�
������'�
%�
%�
%��(�^�^�%�r��7�7�9�9�D�%�%�%�%�%�%�%�%�%�%�%����%�%�%�%���
%�����	�(�#�#�#�#���	�(�#�#�#�#�����K�	�	s}�A2�A&�A2�&A*�*A2�-A*�.A2�1C$�2C�>C$�C�B>�2C�>C	�C�C	�C�	C$�C�C$�$C:c��t�d|��S)zPer-advice pending flagr|)r(r}s rL�
_pending_flagzSmartAdviceUtil._pending_flag�s��)�1�1�4�1�1�1rK�	advice_idc�f�tj�|�|����S)zIs advice in pending state)rkrl�existsr�)rdr�s  rL�is_advice_pendingz!SmartAdviceUtil.is_advice_pending�s$���w�~�~�d�0�0��;�;�<�<�<rKc�2�|�|��dzS)zPer-advice progress storagez	.progress)r�)rdrzs  rL�_progress_filezSmartAdviceUtil._progress_file�s���!�!�$�'�'�+�5�5rKc�x�	t|��S#t$r|j�d��YdSwxYw)Nz#Error while getting user login link�)r�	Exceptionr`�	exception)rd�usernames  rL�_get_user_awp_linkz"SmartAdviceUtil._get_user_awp_link�sN��	�!�(�+�+�+���	�	�	��K�!�!�"G�H�H�H��2�2�	���s��$9�9c�p�|j�|��}|t|dd��fS)zu
        Get advice details from API along with an
        appropriate Advice object by obtained advice type
        �advice�type)rb�advice_detailsr#)rdr�rys   rL�get_detailed_advicez#SmartAdviceUtil.get_detailed_advice�s8���&�5�5�i�@�@���,�X�h�-?��-G�H�H�H�HrKF�dstr��as_jsonc�&�|dz}t|d��5}|r<	tj||��n:#t$r|�|��YnwxYw|�|��ddd��n#1swxYwYt||��dS)z8Dump data inside given dst using .bkp file and then movez.bkp�wN)r�rs�dump�	TypeError�writer4)r�r�r��_tmp_dstr�s     rL�dump_to_filezSmartAdviceUtil.dump_to_file�s�����<��
�(�C�
 �
 �	�B��
�#��I�d�B�'�'�'�'�� �#�#�#��H�H�T�N�N�N�N�N�#�����������	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�(�C� � � � � s1�A6�0�A6�A�A6�A�A6�6A:�=A:�currentc�T����tdtf���fd���}|��S)a
        Smart Advice apply own progress,
        based on current and previous results of 'clwpos get-progress'.
        Returns the maximum progress values among current and previous.
        Previous (latest) is stored inside a pending file-flag.
        ric3��K��j�d��������}	t|��5}t	ditj|����}ddd��n#1swxYwYnY#tt
jf$r@}�j�dt|����t	��}Yd}~nd}~wwxYw�j�d|���|kr�n|V���
���rH�|krD�j�d�����|t���d���dSdSdS)	z}
            Get progress stored in file and return the maximum one among
            current and stored results
            zCurrent progress value: %sNz%Error during reading stored value: %szStored progress value: %szUpdating stored progress: %sT)r�rJ)
r`�debugr�r�r$rsr�r�r�rVr�r�r)�progress_dst�prev�prev_stages�er�r�rds    ���rL�resolve_progressz2SmartAdviceUtil.progress.<locals>.resolve_progress�s������
�K���:�G�D�D�D��.�.�y�9�9�L�
4��,�'�'�I�4�"5�"H�"H��	�$���"H�"H�K�I�I�I�I�I�I�I�I�I�I�I����I�I�I�I����T�1�2�
4�
4�
4���!�!�"I�"%�a�&�&�*�*�*�2�3�3�����������	
4����
�K���9�;�G�G�G�$�{�2�2�'�'��C�C�C��%�%�i�0�0�
0�W�{�5J�5J���!�!�"@�'�J�J�J��!�!�,��w���*.�"�0�0�0�0�0�
0�
0�5J�5Js;�A;�A/�#A;�/A3�3A;�6A3�7A;�;C�6C�C)rr$)rdr�r�r�s``` rL�progresszSmartAdviceUtil.progress�sR�����
�	0�"5�	0�	0�	0�	0�	0�	0�	0�
��	0�4 ��!�!�!rK�_id�
advice_obj�advice_datac�*�|�|��rRd}|�||�|dd����5}|}ddd��n#1swxYwYn|dd}t��}|t	|��fS)z�
        Resolve if advice is in pending status.
        Progress is retrieved for pending advice only.
        Dummy result (0, 0) is returned for other advice states.
        �pending�metadatar�Nr��status)r�r��get_progressr$r)rdr�r�r�r��p�stagess       rL�get_current_statusz"SmartAdviceUtil.get_current_status�s����!�!�#�&�&�	+��F����s�J�$;�$;��
�+�J�7�%9�%9�:�:�
�=>���
�
�
�
�
�
�
�
�
�
�
����
�
�
�
��!��*�8�4�F�(�*�*�F��v�f�~�~�%�%s�
A�A �#A c��|j���}|�||���}	|�|���n*#t$r|j�d��YnwxYw|�|���S)z9Load validated advice list and update it before returning��extended)�current_adviceszDUnable to sync cl-smart-advice plugin during getting list of advices�r�)rb�advice_list�prepare_advices_response�sync_advices_wordpress_pluginr�r`r�ry)rdr��api_response�response_advice_lists    rLr�zSmartAdviceUtil.advice_list�s����*�6�6�8�8��#�<�<�\�T\�<�]�]��	j��.�.�|�.�L�L�L�L���	j�	j�	j��K�!�!�"h�i�i�i�i�i�	j�����}�}�"6�}�7�7�7s�A	�	$A0�/A0c	�p�|j�|��}i}|D]d}|d}||vrg||<||�|dt|d��|�|d��d����ed�|���D��}|�|���S)N�domain�website�urls�advices)r��urls_scannedr�c��g|]
\}}||d���S))r��websitesrJ)�.0r�r�s   rL�
<listcomp>z5SmartAdviceUtil.get_site_statuses.<locals>.<listcomp>s%��n�n�n�?O�v�x�V��:�:�n�n�nrKr�)rb�	site_info�append�lenr�rvry)rdr�r��site_statuses_datar�r�rqs       rL�get_site_statusesz!SmartAdviceUtil.get_site_statuses�s����*�4�4�X�>�>����#�	�	�G��X�&�F��/�/�/�-/�"�6�*��v�&�-�-�"�9�-� #�G�F�O� 4� 4��8�8���9K�L�L�/�/�
�
�
�
�
o�n�Se�Sk�Sk�Sm�Sm�n�n�n���}�}�&�}�)�)�)rKc	��|���}g}|D�]f}|d}|d}|�t��r|�|���Ct	|��}	|	j|d<|r|d}
ddd�}n |�|d|	|��\}
}|r
|	j|d<|
|d<|	j|d	<|	j	|d
<t|	j	|dd��j|d
<|d	rZ|�|	j	|dd��}t|t|	j	|dd�����|d<|�|��|�|����h|S)Nr�r��descriptionr�r)�total_stages�completed_stages�id�detailed_description�
is_premium�module_namer�r��license_status)r�rRrT)�copy�
startswithr?r�r#�short_descriptionr�r��is_premium_featurer�r�name�_get_subscription_statusrXrrr)
rd�from_api�status_from_microservicer�r��visible_advices�item�
advice_itself�advice_type�advice_instancer�r��subscription_statuss
             rLr�z(SmartAdviceUtil.prepare_advices_responses����-�-�/�/�����)	)�)	)�D�!��N�M�'��/�K��%�%�h�/�/�
��&�&�t�,�,�,��1�+�>�>�O�+:�+L�M�-�(�(�
P�&�x�0��*+��C�C���!%�!8�!8��t�9L�9H�$�"P�"P�����
]�8G�8\�
�4�5�&,�M�(�#�*9�*L�M�,�'�+:�+F�M�-�(�.H��+�T�*�-=�j�-I�/K�/K�KO�
�*�+��\�*�
�&*�&C�&C�#�/��j�1A�*�1M�'O�'O�#�04�.� <�'�3�T�*�5E�j�5Q�!S�!S�1�1�1�
�n�-�

� � ��(�(�(��"�"�4�(�(�(�(��rKc�(�������fd�|D��S)Nc�|��g|]�}|�di���d���kr�|�di���d���kr\|�di���d���kr/|�di���d��dk��|���S)r�r�r�r�r�r��outdated)�get)r�r�r�r�r�s  ���rLr�z9SmartAdviceUtil.filter_plugin_advices.<locals>.<listcomp>?s����J�J�J�6��:�:�j�"�-�-�1�1�(�;�;�v�E�E��J�J�z�2�.�.�2�2�:�>�>�(�J�J��J�J�z�2�.�.�2�2�9�=�=��H�H��J�J�x��,�,�0�0��:�:�j�H�H�	�I�H�HrKrJ)rdr�r�r�r�s ``` rL�filter_plugin_advicesz%SmartAdviceUtil.filter_plugin_advices>sC�����J�J�J�J�J�J�[�J�J�J�	JrKc�R�d}t||��rd}t||��rd}|S)zQ
        Determines current subscription status based on feature status.
        �no�activer�)r
r)rdr�r�r�s    rLr�z(SmartAdviceUtil._get_subscription_statusEs@��#���k�8�4�4�	+�"*��"�;��9�9�	,�"+��"�"rKc���|�|��\}}|d}	|dr|d|d<n
|j|d<|dr|d|d<n
|j|d<|d=|�|���S)z<Load validated advice details and update it before returningr�r�r��titler�)r�r�r�ry)rdr�r�r�r�s     rLr�zSmartAdviceUtil.advice_detailsPs���(,�(@�(@��(K�(K�%��o�$�X�.�
�	���'�	Y�4A�-�4P�M�0�1�1�4C�4X�M�0�1���!�	M�+8��+A�M�-�(�(�+:�+L�M�-�(��'�"��}�}�,�}�/�/�/rK�
ACCELERATE_WP�
ignore_errors�
async_mode�source�reason�accept_terms�analytics_datac		�0�t|�|��d�����|r*tj��}	|	r|�|��S|�|||||||��}
|�t||||
|��|rd}
|
S)Nr�)r�r��closerk�fork�manage_advice_status�_exec_advice_managingr7)rd�actionr�r�r�r�r�r�r��child�outputs           rL�
manage_advicezSmartAdviceUtil.manage_advicels���
	
�T�
�
�	�
*�
*�C�0�0�6�6�8�8�8��	<��G�I�I�E��
<��0�0��;�;�;��+�+�F�I�}�j�,2�F�L�J�J���%�(���F�F�TZ�[�[�[��	��F��
rKrc��	|�|��\}}	|tjjk�r�|r!t	|	j|dd��t
|	j|dd��tjkr~tj
dtd��d���tj
�|�|����r(tj|�|����SS|	jdi|d�d|i��\}
}|
r�|j�d��|j�|d|�	��	|�|dd|dd
|dd���nS#t.$r|j�d��Y�n,wxYw�n&|tjjkr�|	jdi|d��\}
}|
r�|j�d
��|r,|j�|d||dt6����n|j�|d|�	��	|�|dd|dd
|dd��nW#t.$r|j�d��Yn1wxYwn,t9td��t;|��z���tj
�|�|����r'tj|�|����n_#tj
�|�|����r(tj|�|����wwxYw|r+|�|�|��|��|S|S)z:Execute managing advice with passed action: apply/rollbackr�r��LICENCE_TERMS_APPROVE_REQUIREDz�License approve required to use this feature. Open AccelerateWP plugin in your control panel, apply advice and accept terms and conditions to proceed with installation.)rq�textr�zApplied successfully�applied)r�r�r�r�r�z:Error while syncing cl-smart-advice plugin on advice applyzRollback successfully�reviewN)r�r�r�r�z=Error while syncing cl-smart-advice plugin on advice rollbackz1Unsupported action with advice, passed action: %srJ) r�rBrH�valuerr�rr�NOT_APPROVEDrsrt�_rkrlr�r�r�rCr`r�rb�
update_advice�_sync_advicer�r�rIrDr+�
ValueErrorrVr�r~)rdrr�r�r�r�r�r�r�r��
action_resultrs            rLrz%SmartAdviceUtil._exec_advice_managing�s���9	9�,0�,D�,D�Y�,O�,O�)�L�/���,�2�2�2��[�-�'�3�\�*�5M�j�5Y�[�[�[�.�'�3�$�Z�0��<�>�>�AU�Ab�c�c� �:�"B� !�#^�!_�!_�'�'���Z�w�~�~�d�0�0��;�;�<�<�
9��	�$�,�,�Y�7�7�8�8�8�8�
9�O)>��(=�)[�)[��Z�@X�)[�)[�LY�)[�)[�)[�%�
�v� �l��K�%�%�&<�=�=�=��'�5�5�	�=F�=C�6�E�E�E�l��)�)�,�z�*B�:�*N�*6�z�*B�8�*L�*6�z�*B�9�*M�O�O�O�O��%�l�l�l���-�-�.j�k�k�k�k�k�l����l��=�1�7�7�7�(@��(@�(\�(\�<�PZ�C[�(\�(\�%�
�v� �o��K�%�%�&=�>�>�>��I��+�9�9�I�AI�AG�AG�H^�I^�H^�A_�:�a�a�a�a�
�+�9�9�I�AI�AG�:�I�I�I�o��)�)�,�z�*B�:�*N�*6�z�*B�8�*L�*6�z�*B�9�*M�O�O�O�O��%�o�o�o���-�-�.m�n�n�n�n�n�o����!o�&!��#V�!W�!W�Z]�^d�Ze�Ze�!e�f�f�f��w�~�~�d�0�0��;�;�<�<�
9��	�$�,�,�Y�7�7�8�8�8����w�~�~�d�0�0��;�;�<�<�
9��	�$�,�,�Y�7�7�8�8�8�8�
9�����	����d�2�2�9�=�=�$�
&�
&�
&��M��Ms]�B#L>�AL>�;F�L>�$F9�5L>�8F9�9BL>�;J
�L>�
$J4�1L>�3J4�40L>�>ANc�(�	|j���}tt|��td�|D�������}n-#t$r t�ddgd��}YnwxYw|�|���S)z#Return advice counters for a serverc�6�g|]}|dddk�|��S)r�r�r	rJ)r�r�s  rLr�z3SmartAdviceUtil.advice_counters.<locals>.<listcomp>�s9��F�F�F��#�H�-�h�7�9�D�D�$�D�D�DrK)�totalr	rr	Nr�)rbr�rXr�r.�fromkeysry)rdr�rqs   rL�advice_counterszSmartAdviceUtil.advice_counters�s���	��.�:�:�<�<�L���,�'�'��F�F�,�F�F�F�G�G����F�F���	?�	?�	?��]�]�G�Y�#7��>�>�F�F�F�	?�����}�}�&�}�)�)�)s�A�'A;�:A;c
�~�|�|��\}}|�|||��\}}|�|j|dd��}|dkr�|�|��}|�|��}tj�|��rt
j	|��|rB|j
d|t|���t|j|dd��d�|�d|i��S|j
d|t|���t|j|dd��d�|��S)zS
        Return current status and progress of managing particular advice.
        r�r�r�)�object_cache)r�rTrRr�rJ)
r�r�r�r�r�r�rkrlr�r�ryrXr)	rdr�r�r�r�r�r�rq�	_progresss	         rLrz$SmartAdviceUtil.manage_advice_status�s���)-�(@�(@��(K�(K�%��o��0�0��O�1=�?�?����#�;�;��'��j�)A�*�)M�O�O���Y����(�(��3�3�F��+�+�I�6�6�I��w�~�~�i�(�(�
%��	�)�$�$�$��

!�$�t�}�	!�!�!%�%8�"�"�"�!=�'�3�$�Z�0��<�!>�!>�	!�	!��	!�	!� �	!�	!�	!�	!��t�}�	
���0����5��+��Z�(��4�6�6�	
�	
��	
�	
�		
rKc�2�|j�dd���}t��}i}|D]�}|�d��}|s)|j�dt
|�����B|�d��|�d��}}t||g��s(|j�dt
|����|||<��|���D]�\}}		|�	||	|��}
|
s#tjd	t
|�����B|�|
���X#t$r#}tjd
|d|i���Yd
}~��d
}~wwxYw|�td�����S)z�
        Updates incompatibilities only, but could be extended to more magic
        how to make microservice know that users/domains/websites no longer exist
        FT)�filtered�show_allr�z9Malformed advice metadata, does not have metadata key: %sr�r�zNMalformed advice metadata, does not have required username or domain field: %sz.Updated metadata for user: %s will not be sentz6Failed to update advice metadata with Smart Advice: %s�fingerprint��extraNz Advices metadata update finishedr�)rbr�r8r�r`�errorrV�allrv�get_updated_extended_metadatar^�warning�sendr�ryr
)rdr��getter�user_domain_pairs�
advice_object�current_adv_metadatar�r��user�user_domain�updated_metadatar�s            rL�update_advices_metadataz'SmartAdviceUtil.update_advices_metadatas���
�-�9�9�5�SW�9�X�X��������,�
	1�
	1�M�#0�#4�#4�Z�#@�#@� �'�
���!�!�"]�"%�m�"4�"4�6�6�6��3�7�7�
�C�C�EY�E]�E]�^f�Eg�Eg�f�H����)�*�*�
=���!�!�"r�"%�&:�";�";�=�=�=�+1��h�'�'�!2�!8�!8�!:�!:�	�	��D�+�
�#)�#G�#G��k�[j�#k�#k� �'���O�$T�VY�Z^�V_�V_�`�`�`�����,�-�-�-�-���
�
�
��
�V��"/��% �!�!�!�!�
���������

�����}�}�!�$F�"G�"G�}�H�H�Hs�4;E�0E�
E3�E.�.E3c�n�|j���}|j�d���}|�|��|�|��}	|�|dd���}|�||||��}|�||||��n9#t$r,|j
�dt|����YdSwxYw|�
��}|�t�|�t�|��}	|	|vri||	<||	||	<|�|��dS)NT��
cache_only)r�r�z/Smart Advice plugin sync failed for website: %s)rbr�rc�im360_advice�extend�get_advice_hash_mapr�r��_run_smart_advice_scriptr�r`r�rV�_read_advices_cache�advice_cache_separator�_update_advices_cache)
rdr�r�r�r��im360_advice_list�advice_hash_map�filtered_advice_list�cached_advices_by_site�keys
          rLrzSmartAdviceUtil._sync_advice1s|���-�9�9�;�;��!�0�=�=��=�N�N�����0�1�1�1��2�2�?�C�C��	�#'�#@�#@��Z^�im�$A�$o�$o� �#'�#=�#=�h��QW�Ym�#n�#n� ��)�)�(�G�V�EY�Z�Z�Z�Z���	�	�	��K�!�!�"S�UX�Y`�Ua�Ua�b�b�b��F�F�	����"&�!9�!9�!;�!;���\�/�\��\�;Q�\�SZ�\�\���,�,�,�*,�"�3�'�&5�c�&:��s�#��"�"�#9�:�:�:�:�:s� AB)�)2C�Cc�t�ddlm}t|��}|��j�|��}|S)Nr)�AWPProvisionAPI)�xray.adviser.awp_provision_apir=r�awp_client_api�	get_usage)rdr�r=�acc_id�	cdn_usages     rL�_get_cdn_usage_statisticsz)SmartAdviceUtil._get_cdn_usage_statisticsIsE��B�B�B�B�B�B�"�8�,�,��#�O�%�%�4�>�>�v�F�F�	��rKc	��t|||��}	t|	||���|||���|�t	d�����S)N)r�r�r��event�feature�
variant_idzAnalytics sentr�)r<r=�lowerryr
)
rdr�rFr�rEr��
journey_id�	user_hashrGr�s
          rL�analytics_reportz SmartAdviceUtil.analytics_reportOsd��7�x��J�W�W���n�#,� &�����$�!(�$.�	0�	0�	0�	0��}�}�!�$4�"5�"5�}�6�6�6rKc���	t|��dd}t||��}n,#t$r|j�d��d}YnwxYw	t|��}n,#t$r|j�d��i}YnwxYw	|j����d��}n,#t$r|j�d��d}YnwxYw	|j�	|��durd	nd
}n,#t$r|j�d��d
}YnwxYwd|i|d
<tt��durdndt��durdnd|durdnd���}|j
dittt!��|�|��|t%d|��t%d|��||�������S)ad
        gets options:
        "panel_type": "cpanel",
        "panel_url": "https:/cpanel-foo.com/", # or https://plesk-bar.com/
        "panel_emails": "root@hosting.com,manager@hostring.com,foo@bar.com",
        "upgrade_url": "https://...",
        "upgrade_url_cdn": "https://...",
        "subscription": dict,
        "notifications": dict,
        r�Unable to get user emailsr�zCannot obtain subscription info�advice_email_notificationz/Cannot obtain im360 advice notification settingFTr�r�z%Cannot obtain im360 protection statusr��
protection�disabled_server�enabled)�email_status�reminders_status�imunify_email_statusr�cdn)rOrPrQrRrSrTrUrJ)rrr�r`r�rrc�get_im360_settingsr��get_im360_protection_statusrXrrryrrNrr�r)rdr�r��emailrT�im360_advice_notification�protection_statusrUs        rL�get_optionszSmartAdviceUtil.get_options[s{��	� ��*�*�1�-�a�0�F�(��6�:�:�E�E���	�	�	��K�!�!�"=�>�>�>��E�E�E�	����	�1�(�;�;�L�L���	�	�	��K�!�!�"C�D�D�D��L�L�L�	����	.�(,�(<�(O�(O�(Q�(Q�(U�(U�Vq�(r�(r�%�%���	.�	.�	.��K�!�!�"S�T�T�T�(-�%�%�%�	.����	%�,0�,@�,\�,\�]e�,f�,f�jn�,n�,n���tx�����	%�	%�	%��K�!�!�"I�J�J�J� $����	%����'/�0A�%B��\�"��.`�.b�.b�fj�.j�.j�*�*�py�2`�2b�2b�fj�2j�2j�.�.�py�.G�4�.O�.O���Uf�
�
�
�
��t�}���v��)�+�+�)-�)@�)@��)J�)J�,1�+G��X`�+a�+a�/K�E�S[�/\�/\�,8�-:�

<�
<�
<� 
� 
���	sE�+.�&A�A�A+�+&B�B�,C�&C.�-C.�2 D�&D<�;D<c�L�t|��}tj|d���S)a,
        Retrieves the LVE limits for a specified user.
        {
            "lve_cpu": {
                "limit": int
            },
            "lve_ep": {
                "limit": int
            },
            "lve_pmem": {
                "limit": int
            },
            "lve_iops": {
                "limit": int
            },
            "lve_io": {
                "limit": int
            },
            "lve_nproc": {
                "limit": int
            },
        }
        or
        {
            "error": str
        }
        r%��indent)r,rsrt�rdr�rqs   rL�
get_limitszSmartAdviceUtil.get_limits�s&��: ��)�)���z�&��+�+�+�+rKc�L�t|��}tj|d���S)a/
        Retrieves the current usage for a specified user.
        {
            "lve_cpu": {
                "usage": int
            },
            "lve_ep": {
                "usage": int
            },
            "lve_pmem": {
                "usage": int
            },
            "lve_iops": {
                "usage": int
            },
            "lve_io": {
                "usage": int
            },
            "lve_nproc": {
                "usage": int
            },
        }
        or
        {
            "error": str
        }
        r%r])r-rsrtr_s   rLr@zSmartAdviceUtil.get_usage�s&��:�x�(�(���z�&��+�+�+�+rKTc��|s|j���}|j�|���}|�|��|�|��}|���}|s|s|�d���St���	��|�
|||�|d������}|�|��|�d���S)Nr.zNo advices found on the serverr�Tr�)�current_advices_jsonzPlugin installed)
rbr�rcr0r1r2r4ryr8�save_clwpos_info�_sync_sa_pluginr�r6)rdr��im360_cachedr7�new_hash_cache_by_site�existing_hash_cache_by_site�
updated_caches       rLr�z-SmartAdviceUtil.sync_advices_wordpress_plugin�s���	@�"�1�=�=�?�?�O�!�0�=�=��=�V�V�����0�1�1�1�!%�!9�!9�/�!J�!J��&*�&>�&>�&@�&@�#�%�	H�.I�	H��=�=�&F�=�G�G�G����'�'�)�)�)��,�,�"�'�!%�!>�!>��Y]�!>�!^�!^�-�
�
�
�
	
�"�"�=�1�1�1��}�}�"4�}�5�5�5rKc��|���}|s#|�td�����St�����|D]r}|�t��\}}}	|�|||d����;#t$r+|j	�
dt|����Y�owxYw|�i���|�td�����S)zJ
        Uninstalls all Smart Advice WordPress plugins on server.
        zNo plugins found on the serverr�N��advices_jsonz2Smart advice plugin removal failed for website: %s)�new_cached_adviceszPlugin uninstalled)
r4ryr
r8rd�splitr5r3r�r`r�rVr6)rdrhr;r�r�r�s      rL�uninstall_wordpress_pluginsz+SmartAdviceUtil.uninstall_wordpress_plugins�s��'+�&>�&>�&@�&@�#�*�	K��=�=�a�(H�&I�&I�=�J�J�J����'�'�)�)�)�.�	�	�C�*-�)�)�4J�*K�*K�'�V�X�w�
��-�-�h���VZ�-�[�[�[�[���
�
�
���%�%�&Z�\_�`g�\h�\h�i�i�i���
����	
�"�"�b�"�9�9�9��}�}�!�$8�"9�"9�}�:�:�:s�=B�2C�Cc
��tjd��i}|���D]�\}}|�t��\}}}	|�|||	||�|����stjd|��|||<�j|r|�||	||��}
nd}
	|�	||	||
��n8#t$r+|j�dt|	����Y��wxYw|||<��t|��t|��z
}|r�tjd��|D]�}|�t��\}}}	tjd|��	|�	||	|d����P#t$r+|j�dt|	����Y��wxYw|S)Nz,Synchronization of smart advice plugin beginz:Website %s does not need update because cache hash matchesz/Smart advice plugin sync failed for website: %szNFound outdated records in cache, removing wordpress plugins for those websitesz!Removing outdated cache record %srk)r^�inforvrnr5�_should_sync_websiter�r�r�r3r�r`r�rV�set)rd�new_hash_advice_cache�existing_hash_advice_cacherc�updated_advicesr;�id_status_hashr�r�r�r9�orphan_hash_recordss            rLrezSmartAdviceUtil._sync_sa_plugins9����C�D�D�D���#8�#>�#>�#@�#@�	2�	2��C��*-�)�)�4J�*K�*K�'�V�X�w��,�,�V�X�w��-G�-K�-K�C�-P�-P�R�R�
��
�Z�\_�`�`�`�'5���$��$�
,�'+�'A�'A�(�G�U[�]q�'r�'r�$�$�'+�$�
��-�-�h���I]�^�^�^�^���
�
�
���%�%�&W�Y\�]d�Ye�Ye�f�f�f���
����$2�O�C� � �"�"<�=�=��DY�@Z�@Z�Z���
	��L�I�
J�
J�
J�*�	
�	
��.1�i�i�8N�.O�.O�+���7���@�#�F�F�F���1�1�(�G�V�Z^�1�_�_�_�_�� �����K�)�)�*[�]`�ah�]i�]i�j�j�j��H������s$�3C�2D�D�7F�2G�Grmc�h�tt�d�d��5}t|��5ttd��5}tjd|��tj||d���ddd��n#1swxYwYddd��n#1swxYwYddd��dS#1swxYwYdS)Nz.lockza+r�z-Updating advice hash map cache with values %sr%r])r�r*r6r^r�rsr�)rm�lock_fd�fs   rLr6z%SmartAdviceUtil._update_advices_cache-sp��
�&�-�-�-�t�
4�
4�	7����!�!�	7�	7��&��,�,�	7�01��M�I�K]�^�^�^��I�(�!�A�6�6�6�6�		7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7����	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7����	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7�	7����	7�	7�	7�	7�	7�	7sW�B'�B�-A8�,B�8A<�<B�?A<�B�B'�B	�B'�B	�B'�'B+�.B+c�.�i}tj�t��rn	t	t��5}tj|��}ddd��n#1swxYwYn,#t$r|j�	d��i}YnwxYw|S)Nz!Unable to read advices cache json)
rkrlr�r*r�rsr�r�r`r�)rdr:r{s   rLr4z#SmartAdviceUtil._read_advices_cache5s���!#��
�7�>�>�+�,�,�	,�
,��+�,�,�:��-1�Y�q�\�\�*�:�:�:�:�:�:�:�:�:�:�:����:�:�:�:����
,�
,�
,���%�%�&I�J�J�J�)+�&�&�&�
,����&�%s4�A)�A�A)�A!�!A)�$A!�%A)�)&B�Bc��||krdSt|��d|z}t||��}t|��sdSdS)NTrF)rr9r;)r�r�r��current_hash�cached_hash�full_website_path�
mu_plugin_dirs       rLrrz$SmartAdviceUtil._should_sync_website@sR���;�&�&��4�#�F�O�O�A�.��8��(��3D�E�E�
��
�.�.�	��4��urKc��tj��}|D]`\}}|�t|�������|�|������a|���S�N)�hashlib�md5rrrV�encode�	hexdigest)�id_status_pairs�hr�r�s    rL�	make_hashzSmartAdviceUtil.make_hashMsp���K�M�M��!0�	&�	&��I�v�
�H�H�S��^�^�*�*�,�,�-�-�-�
�H�H�V�]�]�_�_�%�%�%�%��{�{�}�}�rKc�&��i}|D]l}|d}|d}|d�t�|d�t�|d��}||vrg||<||�|d|df���m�fd�|���D��S)	a�
        Prepare fingerprints for each of the advices generated,
        grouped by the website that advice is assigned to.

        Result example:
        {
          "demo-10-194-0-9.traefik.me;demowp;/": "f43c7bcdccc28fc1ac92b2384f35f9dd"
        }

        Key is combination of domain, usernane and webiste path and
        value is hash against list of advices and their current statuses.
        r�r�r�r�r�r�r�c�|��i|]8\}}|��tt|d����������9S)c�,�t|d��S)Nr)rV)r�s rL�<lambda>z@SmartAdviceUtil.get_advice_hash_map.<locals>.<dictcomp>.<lambda>ns��s�SW�XY�SZ�|�|�rK)r;)r��tupleru)r�r;r�rds   �rL�
<dictcomp>z7SmartAdviceUtil.get_advice_hash_map.<locals>.<dictcomp>msT���
�
�
�$��_�
�����f�_�B[�B[�&\�&\�&\� ]� ]�^�^�
�
�
rK)r5r�rv)rdr�r�r�r�r�r;s`      rLr2z#SmartAdviceUtil.get_advice_hash_mapUs�������	M�	M�F��j�)�H� ��*�K��h�'�C�)?�C��*�AU�C�+�C�-5�i�-@�C�C�C��(�"�"� "���
��S�M� � �+�d�"3�[��5J�!K�L�L�L�L�
�
�
�
�(0���(8�(8�
�
�
�	
rKc��t|d��5}|�|��ddd��dS#1swxYwYdS)z"
        For easy mocking
        r�N)r�r�)rl�contentr{s   rL�_save_custom_phpz SmartAdviceUtil._save_custom_phprs���
�$��_�_�	��
�G�G�G����	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�4�8�8c	��tj|��j�d�}d}tj�||��}gd�}d}t
jd|�d�ddd���}|j�	dd	���	d
d	���
��}	|j�dt|j����t|	��dkrd}n�t|	��dkr�|	d
kr�d
|	�d��vrd}np|	�d��rdd�|��z}nBg}
|D] }||jvr|
�|���!|
rd|	�dd�|
����}|�rC|j�d||��t%|��5tj�|��s5tj�|��stj|d���|�||��ddd��n#1swxYwYt
jdddd|d|gdd���}|j�dt|j����|j�dt|��t|j��t|����dSdS)Nz/.clwposz.php-ini)z/opt/alt/php-xray/z)/opt/cloudlinux-site-optimization-module/z/opt/cloudlinux/z-/usr/sbin/plesk bin site --show-php-settings z | /usr/bin/grep open_basedirT)r�capture_output�shellzopen_basedir =r�z
open_basedir=z!Current open_basedir settings: %sr�none�:zopen_basedir = nonez,open_basedir = {WEBSPACEROOT}{/}{:}{TMP}{/}:zopen_basedir = z0Updating open_basedir setting: %s for domain: %si�)�modez/usr/sbin/plesk�bin�sitez--update-php-settingsz	-settings�rr�z Plesk settings update result: %sz>open_basedir setting updated for domain "%s" from "%s" to "%s")�pwd�getpwnam�pw_dirrkrl�join�
subprocess�run�stdout�replace�stripr`rqrVr�rnr�r�rr�rmrnr�r )
rdr�r��
clwpos_dir�
custom_php�custom_php_full�extra_paths�updated_setting�open_basedir_setting�open_basedir_setting_sanitized�
missing_paths�
extra_pathrqs
             rL�_prepare_php_for_pleskz&SmartAdviceUtil._prepare_php_for_pleskzsz����X�.�.�5�?�?�?�
��
��'�,�,�z�:�>�>��
�
�
��
��)�~�a�F�a�a�a��d�$� 8� 8� 8��*>�)D�)L�)L�M]�_a�)b�)b�)j�)j��R�*!�*!�!&����	'�����<�c�BV�B]�>^�>^�_�_�_��-�.�.�!�3�3�.�O�O�
�/�
0�
0�1�
4�
4�9W�[a�9a�9a��7�=�=�c�B�B�B�B�"7���/�:�:�3�?�?�
s�"P�SV�S[�S[�\g�Sh�Sh�"h���!#�
�"-�9�9�J�!�)=�)D�D�D�%�,�,�Z�8�8�8�� �s�&r�8V�&r�&r�Y\�Ya�Ya�bo�Yp�Yp�&r�&r�O��	4��K���O�Q`�bh�i�i�i�!��*�*�
H�
H��w�~�~�o�6�6�9��7�=�=��4�4�9����%�8�8�8�8��%�%�o��G�G�G�	
H�
H�
H�
H�
H�
H�
H�
H�
H�
H�
H����
H�
H�
H�
H� �^�%6��v�G^�`f�hs�%4�%6�)-�d�D�D�D�F�
�K���?��V�]�AS�AS�T�T�T��K���^�!�&�k�k�!�"6�"=�>�>�!�/�2�2�
4�
4�
4�
4�
4�	4�	4s�6A+H-�-H1�4H1c	��	|�g���}|�||||d��}n#t$rYdSwxYw|�||��}t	jd||��t
j|dd���}|jdkr{|j	�
dt|j��t|j��t|j
��d	d
|j��i���ttd�����dS)
z9
        Uninstall WordPress SmartAdvice plugin.
        r��trueNz@Uninstalling Smart Advice plugin for website %s with advices: %sTr�rzRSmart advice plugin uninstalling failed with exit code: %s, stdout: %s, stderr: %sr�"smart-advice-plugin-sh-returncode-rz'Smart Advice plugin uninstalling failed)ry�!_prepare_smart_advice_script_argsr�_get_smart_advice_script_cmdr^r�r�r��
returncoder`r rVr��stderrr/r
)rdr�r�r��json_string�attrs�commandrqs        rL�_uninstall_wordpress_pluginz+SmartAdviceUtil._uninstall_wordpress_plugin�s4��	��-�-�R�-�0�0�K��:�:�8�W�f�Va�ci�j�j�E�E���	�	�	��F�F�	�����3�3�H�e�D�D���
�X��{�	,�	,�	,����d�4�H�H�H�����!�!��K���r�!�&�"3�4�4�!�&�-�0�0�!�&�-�0�0�"/�1i�V\�Vg�1i�1i�% �	
�
!�
!�
!�)��+T�)U�)U�V�V�V�"�!��/2�
A�Ac	�v�	|�|���}|�||||d��}n#t$rYdSwxYw|�||��}t	jd||��t
j|dd���}|jdkr{|j	�
dt|j��t|j��t|j
��d	d
|j��i���ttd�����|j	�d
t|j����dS)z|
        Install plugin and sync advice
        plugin creation is part of main process -> to handle quota exceeded
        r��falseNz<Updating Smart Advice plugin for website %s with advices: %sTr�rzESmart advice plugin failed with exit code: %s, stdout: %s, stderr: %srr�rz'Smart Advice plugin installation failedz8Smart Advice plugin is installed successfully: output=%s)ryr�rr�r^rqr�r�r�r`r rVr�r�r/r
)	rdr�r�r�rlr�r�r�rqs	         rL�_install_wordpress_pluginz)SmartAdviceUtil._install_wordpress_plugin�s`��
	��-�-�\�-�:�:�K��:�:�8�W�f�Va�cj�k�k�E�E���	�	�	��F�F�	�����3�3�H�e�D�D����S��k�	+�	+�	+����d�4�H�H�H�����!�!��K���e�!�&�"3�4�4�!�&�-�0�0�!�&�-�0�0�"/�1i�V\�Vg�1i�1i�% �	
�
!�
!�
!�)��+T�)U�)U�V�V�V�����S��V�]�+�+�	-�	-�	-�	-�	-r�c���t��}|j���}|j�dt|��t|����|p|S)Nz[Checking whether to install MU plugin: is_smart_advice_disabled=%s, is_im360_mu_disabled=%s)rrc�'is_im360_mu_plugin_disabled_server_wider`rqrV)rd�is_smart_advice_disabled�is_im360_mu_disableds   rL�"_should_wordpress_plugin_installedz2SmartAdviceUtil._should_wordpress_plugin_installed�sp��#X�#Z�#Z� �#�3�[�[�]�]������3��5�6�6��1�2�2�		4�	4�	4�
,�+�G�3G�/G�GrKc�
���fd�}||��}|s��|||��dS����rB�j�dt	|������||||��dSdS)Nc���|s|S|}t��r4d�|D��}�j�dt|�����j���r4d�|D��}�j�dt|�����j�dt|����|S)Nc�v�g|]6}|�di���d��tk�4|��7S�r�r��r�r?�r�r�s  rLr�z\SmartAdviceUtil._run_smart_advice_script.<locals>._filter_by_advice_type.<locals>.<listcomp>��A�� r� r� r�$�4�8�8�H�VX�CY�CY�C]�C]�^d�Ce�Ce�iq�Cq�Cq��Cq�Cq�CqrKz-AccelerateWP advices are filtered, advices=%sc�v�g|]6}|�di���d��tk�4|��7Sr�r�r�s  rLr�z\SmartAdviceUtil._run_smart_advice_script.<locals>._filter_by_advice_type.<locals>.<listcomp>r�rKz&IM360 advices are filtered, advices=%sz4Filtered advices for Smart Advice plugin, advices=%s)rr`rqrVrcr�)�advices_data�
filtered_datards  �rL�_filter_by_advice_typezHSmartAdviceUtil._run_smart_advice_script.<locals>._filter_by_advice_type�s�����
$�#�#�(�M�D�F�F�
f� r� r�-� r� r� r�
��� � �!P�RU�Vc�Rd�Rd�e�e�e��#�K�K�M�M�
_� r� r�-� r� r� r�
��� � �!I�3�}�K]�K]�^�^�^��K���S�UX�Yf�Ug�Ug�h�h�h� � rKz<Smart Advice plugin installation is allowed, advices list=%s)r�r�r`rqrVr�)rdr�r�r�rlr�rs`      rLr3z(SmartAdviceUtil._run_smart_advice_script�s����	!�	!�	!�	!�	!�"*�)�,�7�7���	P��,�,�X�w��G�G�G�G�G�
�
4�
4�
6�
6�	P��K���[� ��.�.�
0�
0�
0��*�*�8�W�f�h�O�O�O�O�O�	P�	PrKr�r�rlc�x�t��}d}d|��}|�|��}	|j�d|	��	t	||��}
n,#t
$r|j�d��d}
YnwxYwt|��d|z}t|��s7|j�d|��ttd�����t|��}|D]2}
|
�d	��|kr|
�d
��}nI�3|j�
d|t|����ttd��|z���|s:|j�
d
|��ttd��|z���|dkrB	|�||��n*#t
$r|j�d��YnwxYwt#||��}|sttd�����t%||��||||||
|	|g}|S)Nzrun.pyz*/opt/alt/php-xray/php/smart-advice-plugin/zGot panel login link: %srMr�rz<[Smart Advice Plugin]: wordpress: %s does not exist, skippedzNon-existing wordpress site�vhost�
php_binaryz*Php data for domain %s was not found in %sz'Unable to get php version for domain %sz)Php version for user: %s was not obtainedz+Php binary was not identified for domain %s�Pleskz-Setting up php for Plesk for SA plugin failedz$Unable to detect MU plugin directory)rr�r`rqrr�r�rrrr
r5r�r rVr/r�r9r:)rdr�r�r�rl�	uninstall�panel�script_name�script_path�panel_user_awp_linkrXr��php_info�php_data�php_binary_pathr��ress                 rLr�z1SmartAdviceUtil._prepare_smart_advice_script_argss���������P�;�P�P��"�5�5�h�?�?������3�5H�I�I�I�	�(��6�:�:�E�E���	�	�	��K�!�!�"=�>�>�>��E�E�E�	����$�F�O�O�A�.��8���+�,�,�	?��K���[�.�
0�
0�
0��Q�<�=�=�>�>�>�'��1�1�� �	`�	`�H��|�|�G�$�$��.�.�"*�,�,�|�"<�"<����/�
�K���J�F�TW�X`�Ta�Ta�b�b�b�(��+T�)U�)U�X^�)^�_�_�_��	d��K���I�&�
(�
(�
(�(��+X�)Y�)Y�\b�)b�c�c�c��G���
W��+�+�H�f�=�=�=�=���
W�
W�
W���%�%�&U�V�V�V�V�V�
W����)��3D�E�E�
��	T�(��+Q�)R�)R�S�S�S�	+�8�]�C�C�C�
��������	
���
s$�A�&B�B�1G�$G/�.G/r�r�c���ttj��rd|g}|�|��n/d|dzdz|d<d�|��}dd|ddd	|g}|S)
Nz/sbin/cagefs_enter_user�'�� �sudoz-uz-sz	/bin/bashz-c)rr �CAGEFSr1r�)r�r�r��command_strs    rLr�z,SmartAdviceUtil._get_smart_advice_script_cmdOsr��%�g�n�5�5�	Q�,�h�7�C��J�J�u������U�1�X�~��+�E�!�H��(�(�5�/�/�K��4��4��d�K�P�C��
rKc��t��}|sttd�����tjdt��t
||��d���S)z;
        Method with handles work with agreements.
        �)This command can only be executed as userrp)rqr3r)r2r/r
rsrtr3r)rdrF�user_contexts   rL�get_agreement_textz"SmartAdviceUtil.get_agreement_textZsd��*�+�+���	Y�(��+V�)W�)W�X�X�X��z��"���.�w��E�E�
�
���	rKc�(�t��}|sttd�����|�|��\}}t	jddt
|��dddt
|��d|jg	dd�	��}|jd
kr�|j	�
dt
|j��t
|j��t
|j��dd
|j��i���ttd��|jz���dS)z�
        Proxy method to AWP which creates subscription
        listening for the status of module and automatic advice appy.
        r�zcloudlinux-awp-userz--userrTz--listenz--advice-idz	--featureTr�rzYCreate subscription smart advice plugin failed with exit code: %s, stdout: %s, stderr: %srz,smart-advice-plugin-subscription-returncode-rz"cloudlinux-awp-user call failed %sN)
r2r/r
r�r�r�rVr�r�r`r r�r�)rdr�r��respr�rqs      rL�create_subscriptionz#SmartAdviceUtil.create_subscriptionhs/��
*�+�+���	Y�(��+V�)W�)W�X�X�X� $� 8� 8�� C� C���o���!��c�,�'�'����3�y�>�>���4�
!
��T�+�+�+�����!�!��K���;�!�&�"3�4�4�!�&�-�0�0�!�&�-�0�0�"/�1s�`f�`q�1s�1s�% �
�
!�
!�
!�)��+O�)P�)P�SY�S`�)`�a�a�a�"�!rK)F)FF)FFr�NFN)FFr�NF)NNNN)NTr�)r�)BrErFrG�__doc__rg�staticmethodrVrary�intr~rr�r��boolr�r�r�r0rrX�objectr�rr�r$r�r�r�r1r�r�r�r�r�rrrrr,rrCrKr[r`r@r�rorer6r4rrr�r
r2r�r�r�r�r�r3r	r�r�r�r�rJrKrLrZrZ[s�������/�/�0�0�0���#��$�����\��
�	9�c�	9�	9�	9��\�	9��4�c�4�c�4�4�4��\�4��3��8�C�=����� �2�C�2�C�2�2�2��\�2�=�3�=�4�=�=�=�=�6�3�6�3�6�6�6�6����#�I�S�I�U�4��<�5H�I�I�I�#�"�I��!�!�#�!�S�!�4�!�D�!�!�!��\�!�#"�#�#"�0C�#"�H[�#"�#"�#"�#"�J&�c�&�v�&�(,�&�16�s�D�y�1A�&�&�&�&�"8�8�S�8�8�8�8��
*�S�
*�
*�
*���
*�.�.�.�.�`J�J�J�	#�	#�	#�0��0��0�0�0�0�8KP�>M�?D�,0���s��4��"&��8;��!��8<��'*��6>�c�]�����,X]�FU�GL�G�G�C�G�C�G�PT�G�*.�G�@C�G�&)�G�@D�G�QY�Z]�Q^�G�G�G�G�R*��*�*�*�*� (
�c�(
�c�(
�(
�(
�(
�T*I�*I�*I�X;�;�;�0����KO�EI�	7�	7�	7���	7��4�4���4�l�,�,���,�>�,�,���,�>6�6�6�6�.;�;�;�.+�+�+�+�Z�7�$�7�7�7��\�7�	&�T�	&�	&�	&�	&��
�
��\�
�����\��
�d�3��8�n�
�
�
�
�:����\��94�94�94�vW�W�W�2-�-�-�6H�H�H�P�P�P�P�:5<�>�>�4�PS�9�>�dg�>�@D�S�	�>�>�>�>�@��s��4��9���c������\�����b�b�b�b�brKrZ)`r�rsr^rkr�r�r��
contextlibr�dataclassesrr�typingrrrr	r
�enumr�clwpos.user.configr�clwpos.papir
rrrrrrrrrr�clcommon.cpapirrrrrr�clcommon.clwpos_libr�clcommon.clpwdr�clcommon.constr �xrayr!r
�advice_typesr#r�r$�	apiclientr&r'�internal.constantsr(r)r*r+�internal.user_limitsr,r-�internal.exceptionsr.r/�internal.user_plugin_utilsr0r1r2�internal.utilsr3r4r5r6�analytics.utilsr7�xray.adviser.clwpos_getr8� xray.smart_advice_plugin_helpersr9r:� xray.smart_advice_plugin_managerr;r<�xray.analyticsr=�xray.imunify_managerr>r?r5rBrNrZrJrKrL�<module>rs������������	�	�	�	�����
�
�
�
�����%�%�%�%�%�%�)�)�)�)�)�)�)�)�3�3�3�3�3�3�3�3�3�3�3�3�3�3�������3�3�3�3�3�3�������������������������������������������+�*�*�*�*�*�*�*�*�*�*�*�"�"�"�"�"�"�������-�-�-�-�-�-�)�)�)�)�)�)�.�.�.�.�.�.�.�.�������������A�@�@�@�@�@�@�@�C�C�C�C�C�C�C�C�q�q�q�q�q�q�q�q�q�q�Q�Q�Q�Q�Q�Q�Q�Q�Q�Q�Q�Q�:�:�:�:�:�:�0�0�0�0�0�0���������]�\�\�\�\�\�\�\�+�+�+�+�+�+�9�9�9�9�9�9�9�9��������D����
�����������jb�jb�jb�jb�jb�jb�jb�jb�jb�jbrK