Your IP : 216.73.216.57


Current Path : /opt/imunify360/venv/lib64/python3.11/site-packages/imav/wordpress/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib64/python3.11/site-packages/imav/wordpress/__pycache__/cli.cpython-311.pyc

�

���hW���dZddlZddlZddlmZmZddlmZddlm	Z	m
Z
mZeje
��Zdefd�Zdefd�Zdefd	�Zdefd
�Zdefd�Zdefd�ZdS)
u

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.


This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
See the GNU General Public License for more details.


You should have received a copy of the GNU General Public License
 along with this program.  If not, see <https://www.gnu.org/licenses/>.

Copyright © 2019 Cloud Linux Software Inc.

This software is also available under ImunifyAV commercial license,
see <https://www.imunify360.com/legal/eula>
�N)�	check_run�
CheckRunError)�WPSite)�PLUGIN_PATH�PLUGIN_SLUG�utils�sitec��zK�tj|j��j}t	j||���d{V��}gt	j||j���d�d�tt���d�d�}t	j
||��}t�d|����t|���d{V��dS)zFInstall the Imunify Security WordPress plugin on given WordPress site.N�plugin�install�
--activate�--forcezInstalling wp plugin ��pwd�getpwuid�uid�pw_namer�get_php_binary_path�
wp_wrapper�docroot�strr�build_command_for_user�logger�infor�r	�username�php_path�args�commands     �G/opt/imunify360/venv/lib/python3.11/site-packages/imav/wordpress/cli.py�plugin_installr!'s������|�D�H�%�%�-�H��.�t�X�>�>�>�>�>�>�>�>�H��	�	�(�D�L�	1�	1����	��	�K���	�
	��	�
�D��*�8�T�:�:�G�
�K�K�1��1�1�2�2�2�
�G�
�
����������c��zK�tj|j��j}t	j||���d{V��}gt	j||j���d�d�tt���d�d�}t	j
||��}t�d|����t|���d{V��dS)z�
    Update the Imunify Security WordPress plugin on given WordPress site.

    Currently, this is the same as install, but in the future it may differ.
    Nrrr
rzUpdating wp plugin rrs     r �
plugin_updater$<s������|�D�H�%�%�-�H��.�t�X�>�>�>�>�>�>�>�>�H��	�	�(�D�L�	1�	1����	��	�K���	�
	��	�
�D��*�8�T�:�:�G�
�K�K�/�g�/�/�0�0�0�
�G�
�
���������r"c��\K�tj|j��j}t	j||���d{V��}gt	j||j���d�d�t�d�}t	j	||��}t�d|����t|���d{V��dS)z<Uninstall the imunify-security wp plugin from given wp site.Nr�	uninstallz--deactivatezUninstalling wp plugin )
rrrrrrrrrrrrrrs     r �plugin_uninstallr'Us������|�D�H�%�%�-�H��.�t�X�>�>�>�>�>�>�>�>�H��	�	�(�D�L�	1�	1����	��	�	�
	��D��*�8�T�:�:�G�
�K�K�3�'�3�3�4�4�4�
�G�
�
���������r"c��K�tj|j��j}t	j||���d{V��}gt	j||j���d�d�t�d�}t	j	||��}t�d|����	t|���d{V��}|�
d�����}|sdS|�d�	��d
S#t $r+}t�d|j��Yd}~dSd}~wt&$r&}t�d|��Yd}~dSd}~wwxYw)
zTGet the version of the imunify-security wp plugin installed on given WordPress site.Nr�getz--field=versionzGetting wp plugin version zutf-8��)�maxsplitrz0Failed to get wp plugin version. Return code: %sz-Failed to decode wp plugin version output: %s)rrrrrrrrrrrrr�decode�strip�splitr�error�
returncode�UnicodeDecodeError)r	rrrr�result�output�es        r �get_plugin_versionr6is������|�D�H�%�%�-�H��.�t�X�>�>�>�>�>�>�>�>�H��	�	�(�D�L�	1�	1����	��	�	�
	��D��*�8�T�:�:�G�
�K�K�6�W�6�6�7�7�7�� ��)�)�)�)�)�)�)�)�����w�'�'�-�-�/�/���	��2��|�|�Q�|�'�'��*�*���������>�
�L�	
�	
�	
��t�t�t�t�t������������D�a�H�H�H��t�t�t�t�t��������s*�>C4�C4�4
E�> D$�$
E�1E�Ec��~K�tj|j��j}t	j||���d{V��}gt	j||j���d�d�t�}t	j	||��}t�d|����	t|���d{V��n#t$rYdSwxYwdS)zMCheck if the imunify-security wp plugin is installed on given WordPress site.Nr�is-installedz#Checking if wp plugin is installed FT)rrrrrrrrrrrrrrrs     r �is_plugin_installedr9�s������|�D�H�%�%�-�H��.�t�X�>�>�>�>�>�>�>�>�H��	�	�(�D�L�	1�	1����	��	�	�D��*�8�T�:�:�G�
�K�K�?�g�?�?�@�@�@���� � � � � � � � � � �������u�u�����
�4s�B,�,
B:�9B:c��pK�tj|j��j}t	j||���d{V��}gt	j||j���d�d�}t	j||��}t�
d|����	t|���d{V��n#t$rYdSwxYwdS)zJCheck if WordPress is installed and given site is accessible using WP CLI.N�corer8z#Checking if WordPress is installed FT)
rrrrrrrrrrrrrrs     r �is_wordpress_installedr<�s������|�D�H�%�%�-�H��.�t�X�>�>�>�>�>�>�>�>�H��	�	�(�D�L�	1�	1����	��D�
�*�8�T�:�:�G�
�K�K�?�g�?�?�@�@�@���� � � � � � � � � � �������u�u������4s�B%�%
B3�2B3)�__doc__�loggingr�defence360agent.utilsrr�imav.model.wordpressr�imav.wordpressrrr�	getLogger�__name__rr!r$r'r6r9r<�r"r �<module>rEsR����*����
�
�
�
���������(�'�'�'�'�'�����������
��	�8�	$�	$���v�����*�f�����2������(�6�����@�F�����0�v������r"

?>