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/clcommon/cpapi/__pycache__/pluginlib.cpython-37.pyc
B

����F�@s�dZddlmZddlmZddlmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZddlmZmZd	d
lmZmZmZd	dlmZeddd
�Ze�e�dZdZdZdZejddd�r�ej ddd�Zej!�"e�s�e#d�ej!�$ej!�%e&�d�Z'dZ(dZ)dZ*dZ+dZ,dZ-dZ.e(de)de*de+d e,d!e-d"e.d#iZ/d$d%�Z0d0d&d'�Z1d1d(d)�Z2d*d+�Z3d,d-�Z4efd.d/�Z5dS)2z
Library to work with plug-ins
�)�print_function)�absolute_import)�divisionN)�
import_module)�ConfigParser)�lvectl_custompanel_script�CLSYSCONFIG�)�CACHE_CPNAME�UNKNOWN_CP_NAME�UNKNOWN_CP_IMPORT)�PluginImportErrorF)Z
interpolation�strictZ
__cpname__Zdetectzclcommon.cpapiZcpapiZ	plugindir)ZsectionZoptionz5WARNING: plugindir is configured, but doesn't exists!z
apilink.pyZcPanelZDirectAdminZPleskZ
ISPManagerZ	InterWorxZUnknownZ
IntegratedZcpanelZdirectadminZpleskZ
ispmanagerZ	interworxZbackward_pluginZvendorscCs�d\}}tj�d�r$ttt}}n�tj�d�r@ttt}}n�tj�d�sXtj�d�rhttt}}nxtj�d�r�ttt}}n\tj�d�s�tj�d�r�t	tt	}}n4tj�d	�r�t
tt
}}nt�d
k	r�ttt}}||fS)z�
    This function will try to detect our officially supported control panels
    :return: tuple of CP name and CP plugin name to import
    )NNz!/opt/cpvendor/etc/integration.iniz/usr/local/cpanel/cpanelz"/usr/local/directadmin/directadminz(/usr/local/directadmin/custombuild/buildz/usr/local/psa/versionz/usr/local/ispmgr/bin/ispmgrz/usr/local/mgr5z/usr/local/interworxN)
�os�path�isfile�INTEGRATED_NAME�OFFICIAL_PLUGINS�CPANEL_NAME�DIRECTADMIN_NAME�
PLESK_NAME�isdir�ISPMANAGER_NAME�INTERWORX_NAMEr�UNKNOWN_NAME)Z
panel_nameZofficial_plugin_name�r��/builddir/build/BUILDROOT/alt-python27-cllib-3.4.1-1.el9.cloudlinux.x86_64/opt/alt/python37/lib/python3.7/site-packages/clcommon/cpapi/pluginlib.py�detect_panel_fast@s"
rcCs$|rtd�t|��Sddlm}|S)Nz
{}.plugins.{}r	)�api)r�format�PLUGINS_PKG_PREFIXZapilinkr)Zplugin_nameZ
_apipluginrrr�get_cp_plugin_module[sr!cCstj�tj�t�|�}tj�|d�}dd�t�|�D�}x�|D]�}|dkrLq>d�t||�}d||f}yt|�}Wn*t	k
r�|r�w>nt
d|f��YnXy|��}	|	��}
||
dfSt
ttfk
�r�}zt�tjd	�|t|���Wd
d
}~XYq>Xq>WdS)a�
    Scan directory for presence of plugins.  Plugin is a file that has
    the extension ".py" and a non-empty variable "__cpname__" (the name
    of the control panel).  The file must contain a function "detect"
    which returns True in case of presence of the corresponding
    control panel.

    >>> detectplugin('plugins')
    ('from .plugins import cpanel as api', 'cPanel')

    :param plugin_pack: package name or the name of the plug-ins directory
                       ('cache' - cache plugins users; 'plugins' - officially supported plug-ins)
    :rtype: tuple
    :return: a pair of values: (line to import the package, the name of the control panel)
    z*.pycSs$g|]}tj�tj�|��d�qS)r)rr�splitext�basename)�.0Zpy_full_pathrrr�
<listcomp>xsz detectplugin.<locals>.<listcomp>�__init__z{}.{}.{}zfrom .%s import %s as apizCan not import %s plugin�namez8cpapi: Plugin {} does not satisfy cpapi requirements:
{}N)NN)rr�join�dirname�__file__�globrr r�ImportErrorr
ZPanelPluginZget_cp_description�AttributeError�	TypeError�KeyError�syslogZLOG_WARNING�str)Zplugin_pack�
ignore_errorsZ
plugin_dirZplugin_path_pattern�modulesZmod_nameZabsolute_module_name�
import_stringrZpanel_classZ
panel_data�excrrr�detectplugines2
$r6cCs"t��}|dkrdSt�|�dS)zJ
    Get current user's username based on os.getuid()
    :rtype: str
    r�root)r�getuid�pwd�getpwuid)Zuidrrr�getuser�sr;cCs>t|d���ddl}|�|�tjd�tj|�ddd�dS)zAcreate (or rewrite) an empty __init__.py and it's .pyc/.pyo parts�wrNz{} -O -m py_compile "{}"Tz	/bin/bash)�shell�
executable)	�open�close�
py_compile�compile�
subprocess�runr�sysr>)�	init_pathrArrr�_reinit_module�s
rGc

CsVd}d}tj�tj�t�|�}t�|�|rFtj�|�rFt�||�n
t�	|�t�
|d�tj�|d�}t|�yt|�\}}Wn8t
k
r�}zd\}}td�|��Wdd}~XYnX|dkr�t�|�t�	|�t|�t|dd�\}}|dk�rtt}}td	|�|�rRttd
�}|�|�|��ttd
�}	|	�|d�|	��dS)N�cacheZpluginsi�z__init__.py)NNzWARNING: {}T)r2zHWARNING: can not detect control panel; the control panel is set to "%s" r<�
)rrr(r)r*�shutilZrmtreerZcopytree�mkdir�chmodrGr6r
�printrrrr?r
�writer@�
API_LINK_PATH)
Zplugins_dirZ	CACHE_DIRZPLUGINS_PATHZ	cache_dirrFr4Zcpnamer5Zcpname_cacheZapi_link_streamrrr�
rebuild_cache�s<

 






rP)N)F)6�__doc__Z
__future__rrrrrCrEr9r+rJr0�	importlibrZconfigparserrZclcommon.clcustomscriptrrZconstr
rrZcpapiexceptionsr
Zclsysconfig�readZCONTROLPANELNAME_VARZDETECTFUNCNAME_VARr ZPLUGINS_DIRZ
has_option�getr�existsrMr(r)r*rOrrrrrrrrrr!r6r;rGrPrrrr�<module>	s\



1