|
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/__pycache__/ |
Upload File : |
B
A�c- � @ s� d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm Z d dl
mZmZ d dl
mZ d dlmZ e d �Zeee ed
�dd�Zeee ed
�d
d�Zdee ed�dd�Zdd� Zdd� ZdS )� N)�List)�cpapi)�drop_privileges)�
setup_logging)�get_allowed_modules�ALL_OPTIMIZATION_MODULES)�get_admin_options)�
UserConfigZclwpos_statistics)�user�checked_modules�returnc
C sf d}y*t | �� t| �}|�|�}W dQ R X W n2 tk
r` } zt�dt|�� |S d}~X Y nX |S )zW
Calculates total count of sites with at least one enabled
module per user
r Nz3Error while getting info from clwpos user config %s)r r Z"get_enabled_sites_count_by_modules� Exception�_loggerZwarning�str)r
r �countZuc�e� r �=/opt/alt/python37/lib/python3.7/site-packages/clwpos/stats.py�,get_sites_count_with_enabled_wpos_statistics s
r c sP yt �| �j}W n tk
r0 t�d| � dS X t|�� t� fdd�|D ��S )z:
Checks if there are any allowed modules for user
zUnable to get uid for %sFc 3 s | ]}|� kV qd S )Nr )�.0Zchecked_module)�allowed_modulesr r � <genexpr>3 s z?get_users_count_with_allowed_wpos_statistics.<locals>.<genexpr>)�pwd�getpwnamZpw_uid�KeyErrorr �debugr �any)r
r Zuidr )r r �,get_users_count_with_allowed_wpos_statistics) s r �allowed)�modules�kindc C sH d}t �� }x6|D ].}|dkr2t|| �r@|d7 }q|t|| �7 }qW |S )z�
Returns total count of users with allowed wpos module
or total count of sites with enabled wpos module
for all panel users on server
r r � )r Zcpusersr r )r r Ztotal_countZpanel_usersr
r r r � _get_wpos_statistics_total_count6 s
r"