%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python37/lib/python3.7/site-packages/clwpos/__pycache__/
Upload File :
Create Path :
Current File : //opt/alt/python37/lib/python3.7/site-packages/clwpos/__pycache__/stats.cpython-37.pyc

B

�4Lb��@s�ddlZddlmZddlmZddlmZddlmZddl	m
Z
mZddlm
Z
ed�Zeeeed	�d
d�Zeeeed	�dd
�Zdeeed�dd�Zdd�ZdS)�N)�List)�cpapi)�drop_privileges)�
setup_logging)�get_allowed_modules�ALL_OPTIMIZATION_MODULES)�
UserConfigZclwpos_statistics)�user�checked_modules�returnc
Csfd}y*t|��t|�}|�|�}WdQRXWn2tk
r`}zt�dt|��|Sd}~XYnX|S)zW
    Calculates total count of sites with at least one enabled
    module per user
    rNz3Error while getting info from clwpos user config %s)rrZ"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_statisticss
rcsPyt�|�j}Wn tk
r0t�d|�dSXt|��t�fdd�|D��S)z:
    Checks if there are any allowed modules for user
    zUnable to get uid for %sFc3s|]}|�kVqdS)Nr)�.0Zchecked_module)�allowed_modulesrr�	<genexpr>2sz?get_users_count_with_allowed_wpos_statistics.<locals>.<genexpr>)�pwd�getpwnamZpw_uid�KeyErrorr
�debugr�any)r	r
Zuidr)rr�,get_users_count_with_allowed_wpos_statistics(sr�allowed)�modules�kindcCsHd}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
    rr�)rZcpusersrr)rrZtotal_countZpanel_usersr	rrr� _get_wpos_statistics_total_count5s


r!cCslt�t�d�}ttd�|dd<ttd�|dd<x4tD],}t|gd�|d|<t|gd�|d|<q8W|S)zj
    Returns current statistics with enabled sites/allowed users counters
    per module and in total
    )�
allowed_users�
enabled_sitesrr"ZtotalZenabledr#)�dictr!r)�result�modulerrr�fill_current_wpos_statisticsFs

r')r)r�typingrZclcommonrZclcommon.clpwdrZclwpos.logsetuprZclwpos.optimization_modulesrrZclwpos.user.configrr
r�intrrr!r'rrrr�<module>	s


Zerion Mini Shell 1.0