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/clwpos/user/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

A�co%�@s�ddlmZddlZddlZddlZddlZddlmZmZddl	m
Z
ddlmZddl
mZmZmZddlmZddlmZdd	lmZdd
lmZGdd�de�ZGd
d�de�ZdS)�)�absolute_importN)�Iterable�Optional)�ALL_OPTIMIZATION_MODULES)�
setup_logging)�get_relative_docroot�create_clwpos_dir_if_not_exists�is_run_under_user)�
is_wp_path)�	constants)�	WposError)�gettextc@seZdZdZdS)�ConfigErrorz^
    Used for all exceptions during handling clwpos user config
    in UserConfig methods
    N)�__name__�
__module__�__qualname__�__doc__�rr�C/opt/alt/python37/lib/python3.7/site-packages/clwpos/user/config.pyrsrc@s�eZdZdZej�dejej	�Z
ej�d�Zied�Zdd�Z
dd�Zed	�d
d�Zdd
�Zdd�Zed�dd�Zd#eeeeeed�dd�Zeeedd�dd�Zeeedd�dd�Zdd�Zeeed�dd �Zd!d"�ZdS)$�
UserConfigzQ
    Class to manage clwpos user config - read, write, set params in config.
    z	{homedir}Zmb)�docrootsZmax_cache_memorycCsNt�sttd���||_t�|�j|_|jj	|jd�|_
tt�|_
t|�dS)Nz&Trying to use UserConfig class as root)�homedir)r	r�_�username�pwd�getpwnam�pw_dirr�CONFIG_PATH�format�config_pathrr�_loggerr)�selfrrrr�__init__-s
zUserConfig.__init__c	Cs`y&t|jd��}t�|���SQRXWn4tk
rZt��}tt	d�|j|d�d��YnXdS)z4
        Reads config from self.config_path
        �rNz@Error while reading config %(config_path)s: %(exception_string)s)rZexception_string)�message�context)
�openr�json�loads�read�	Exception�	traceback�
format_excrr)r!�fZ
exc_stringrrr�read_config7szUserConfig.read_config)�configc
Csry6tj|ddd�}t|jd��}|�|�WdQRXWn6tk
rl}zttd�d|id��Wdd}~XYnXdS)	z=
        Writes config (as json) to self.config_path
        �T)�indentZ	sort_keys�wNzDAttempt of writing to config file failed due to error:
%(exception)s�	exception)r$r%)r'�dumpsr&r�writer*rr)r!r/Zconfig_jsonr-�errr�write_configEszUserConfig.write_configcCstj�|j�S)z?
        Checks if user customized his config already.
        )�os�path�existsr)r!rrr�is_default_configSszUserConfig.is_default_configcCsF|��r|jSy|��}Wntk
r0|jSXt|t�r@|S|jS)zP
        Returns default config or config content from self.config_path
        )r;�DEFAULT_CONFIGr.r�
isinstance�dict)r!r/rrr�
get_configYszUserConfig.get_config)�paramscCs4|��}x|��D]\}}|||<qW|�|�dS)a�
        Set outer (not "docroots") params in config.
        Example:
        Old config:
        {
            "docroots": ...,
            "max_cache_memory": "123mb",
        }
        Input params:
        {
            "max_cache_memory": "1024mb",
            "param": "value"
        }
        New config:
        {
            "docroots": ...,
            "max_cache_memory": "1024mb",
            "param": "value"
        }
        N)r?�itemsr7)r!r@r/�key�valuerrr�
set_paramsiszUserConfig.set_paramsN)�domain�wp_path�moduler/�returnc	
Cs8|p
|��}yt||j�}WnJtk
rf}z,|jj|dd�ttd�||jd�d��Wdd}~XYnXtt	j
�|j||��s�ttd�d|id��|tkr�ttd�|td	�d��y$|d
}|�
|i��
|g�}||kStttfk
�r2}z8|jjd|j�d|��dd�ttd
�d|jid��Wdd}~XYnXdS)NT)�exc_infozDCan't find docroot for domain '%(domain)s' and homedir '%(homedir)s')rEr)r$r%z)Wrong wordpress path '%(wp_path)s' passedrFz9Invalid module %(module)s, available choices: %(choices)s)rG�choicesrzconfig z is broken: z@Config is broken.
Repair %(config_path)s or restore from backup.r)r?rrr*r Zwarningrrr
r8r9�joinr�get�KeyError�AttributeError�	TypeErrorr)	r!rErFrGr/�docrootr6rZmodule_inforrr�is_module_enabled�s2"zUserConfig.is_module_enabled)rErFrGrHc
Csyt||j�}WnBtk
rR}z$|j�|�ttd�d|id��Wdd}~XYnXttj	�
|j||��s~ttd�d|id��|tkr�ttd�|td�d��|��}|�
||||�s�dS|d||�|�|d||s�|d||=|d|�s|d|=|�|�dS)	Nz,Docroot for domain '%(domain)s' is not foundrE)r$r%z)Wrong wordpress path '%(wp_path)s' passedrFz9Invalid module %(module)s, available choices: %(choices)s)rGrJr)rrr*r r3rrr
r8r9rKrr?rQ�remover7)r!rErFrGrPr6r/rrr�disable_module�s0
zUserConfig.disable_modulec
Cs&yt||j�}WnBtk
rR}z$|j�|�ttd�d|id��Wdd}~XYnXttj	�
|j||��s~ttd�d|id��|tkr�ttd�|td�d��|��}|�
||||�r�dSd|kr�i|d<||dkr�i|d|<||d|k�rg|d||<|d||�|�|�|�dS)	Nz,Docroot for domain '%(domain)s' is not foundrE)r$r%z)Wrong wordpress path '%(wp_path)s' passedrFz9Invalid module %(module)s, available choices: %(choices)s)rGrJr)rrr*r r3rrr
r8r9rKrr?rQ�appendr7)r!rErFrGrPr6r/rrr�
enable_module�s4zUserConfig.enable_moduleccsRxL|��d��D]8\}}x.|��D]"\}}x|D]}|||fVq2Wq$WqWdS)Nr)r?rA)r!�doc_root�
doc_root_inforF�module_names�namerrr�enabled_modules�s
zUserConfig.enabled_modules)�module_namerHccs8x2|��D]&\}}}||kr
tj�|j||�Vq
WdS)zI
        Return absolute WP paths with specified module enabled.
        N)rZr8r9rKr)r!r[rVrFrYrrr�wp_paths_with_enabled_module�sz'UserConfig.wp_paths_with_enabled_modulecsZd}xP|���di���D]8\}}x.|��D]"\}�|t�fdd�|D��7}q,WqW|S)z<
        Returns count of sites with enabled module
        rrc3s|]}|�kVqdS)Nr)�.0Zchecked_module_name)rXrr�	<genexpr>
sz@UserConfig.get_enabled_sites_count_by_modules.<locals>.<genexpr>)r?rLrA�any)r!Zchecked_module_namesZsites_countrrWr)rXr�"get_enabled_sites_count_by_moduless
"z-UserConfig.get_enabled_sites_count_by_modules)N)rrrrr8r9rKrZ
USER_WPOS_DIRZUSER_CLWPOS_CONFIGrZDEFAULT_MAX_CACHE_MEMORYr<r"r.r>r7r;r?rD�strr�boolrQrSrUrZrr\r`rrrrr%s 

"('r)Z
__future__rr'r8rr+�typingrrZclwpos.optimization_modulesrZclwpos.logsetuprZclwpos.utilsrrr	Zclcommon.clwpos_libr
ZclwposrZclwpos.cl_wpos_exceptionsrr
rr�objectrrrrr�<module>s

https://t.me/AnonymousX5 - 2025