%PDF- %PDF-
Direktori : /opt/alt/python37/lib/python3.7/site-packages/clwpos/__pycache__/ |
Current File : //opt/alt/python37/lib/python3.7/site-packages/clwpos/__pycache__/stats.cpython-37.pyc |
B �4Lb� � @ s� d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl m Z mZ d dlm Z ed�Zeee ed �d d�Zeee ed �dd �Zdee ed�dd�Zdd� ZdS )� N)�List)�cpapi)�drop_privileges)� setup_logging)�get_allowed_modules�ALL_OPTIMIZATION_MODULES)� 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>2 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_count5 s r! c C sl t � t � d�} ttd�| d d<