ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib/python3.11/site-packages/clwpos/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/clwpos/__pycache__/stats.cpython-311.pyc

�

�2�f0���ddlZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZddlmZmZmZmZmZmZdd	lmZdd
lmZddlmZe
d��Zd
edeedefd�Zd
edeedefd�Z d
edeedefd�Z!d
edeedefd�Z"				d&deededeefd�Z#d�Z$d'defd�Z%d�Z&d�Z'd �Z(d!e)d"e*d#ed$efd%�Z+dS)(�N)�List)�cpapi)�drop_privileges)�CLWPOS_WHMCS_STATS_FILE)�
setup_logging)�ALL_OPTIMIZATION_FEATURES)�get_allowed_modules�get_visible_modules�get_allowed_suites�PremiumSuite�
ALL_SUITES�AWPSuite)�get_server_wide_options)�
UserConfig)�CDNSuitePro�clwpos_statistics�user�checked_modules�returnc�&�d}	t|��5t|��}|�|��}ddd��n#1swxYwYnA#t$r4}t�dt
|����|cYd}~Sd}~wwxYw|S)zW
    Calculates total count of sites with at least one enabled
    module per user
    rNz3Error while getting info from clwpos user config %s)rr�"get_enabled_sites_count_by_modules�	Exception�_logger�warning�str)rr�count�uc�es     �C/opt/cloudlinux/venv/lib64/python3.11/site-packages/clwpos/stats.py�,get_sites_count_with_enabled_wpos_statisticsr "s���

�E��
�T�
"�
"�	K�	K��D�!�!�B��9�9�/�J�J�E�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K�	K����	K�	K�	K�	K����������M�s�ST�v�v�V�V�V�����������������Ls?�A�%A�A�A�A�A�A�
B�)B	�B�	Bc����	tj|��j}n,#t$rt�d|��YdSwxYwt
|���t�fd�|D����S)z:
    Checks if there are any allowed modules for user
    �Unable to get uid for %sFc3� �K�|]}|�vV��	dS�N�)�.0�checked_module�allowed_moduless  �r�	<genexpr>z-is_module_allowed_for_user.<locals>.<genexpr><�(�����W�W�^�~��0�W�W�W�W�W�W�)�pwd�getpwnam�pw_uid�KeyErrorr�debugr	�any)rr�uidr(s   @r�is_module_allowed_for_userr32������l�4� � �'���������
�
�0�$�7�7�7��u�u�����*�#�.�.�O��W�W�W�W��W�W�W�W�W�W���%A�Ac����	tj|��j}n,#t$rt�d|��YdSwxYwt
|���t�fd�|D����S)z:
    Checks if there are any visible modules for user
    r"Fc3� �K�|]}|�vV��	dSr$r%)r&r'�visible_moduless  �rr)z-is_module_visible_for_user.<locals>.<genexpr>Ir*r+)r,r-r.r/rr0r
r1)rrr2r8s   @r�is_module_visible_for_userr9?r4r5�suitesc����	tj|��j}n,#t$rt�d|��YdSwxYwt
|���t�fd�|D����S)Nr"Fc3� �K�|]}|�vV��	dSr$r%)r&�
checked_suite�allowed_suitess  �rr)z,is_suite_allowed_for_user.<locals>.<genexpr>Ss(�����K�K�=�}��.�K�K�K�K�K�Kr+)r,r-r.r/rr0rr1)rr:r2r>s   @r�is_suite_allowed_for_userr?Ls������l�4� � �'���������
�
�0�$�7�7�7��u�u�����(��,�,�N��K�K�K�K�F�K�K�K�K�K�Kr5�allowedF�modules�kind�allowed_by_suitesc�B�d}tj��}|D]�}|rt||��s�|�t||��s�(|dkr|dz
}�4|dkrt	||��r|dz
}�P|r!|tt
||����z
}�s|t
||��z
}��|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
    rNr@��visible)r�cpusersr3r?r9�boolr )rArB�allowed_by_modulesrC�per_user�total_count�panel_usersrs        r� _get_wpos_statistics_total_countrMVs����K��-�/�/�K��[�[���	�&@��w�&O�&O�	���(�1J�4�Qb�1c�1c�(���9����1��K�K�
�Y�
�
�)�$��8�8�
!��q� ����
[��t�$P�QU�W^�$_�$_�`�`�`����K�D�RY�Z�Z�Z����r+c��tj��}d}d}|D]]}t|tj��s�t|tj��r!t|tj��r�R|dz
}�X|dz
}�^||fS)z

    rrE)rrGr r�feature_setr9r)rL�visible_premium�disallowed_premiumrs    r�*_get_premium_potential_upgrades_statisticsrRys����-�/�/�K��O����$�$��;�D�(�BV�W�W�	��%�d�L�,D�E�E�	$�;�D�,�BZ�[�[�
���q� �O�O��!�#����.�.�.r+�suitec�v�d}tj��}|D]�}t||g��s�tt|j��}|dkr tt|j��}n2|dkr,tt|�����}t||��r|dz
}��|S)z?
    Returns total count of users with active wpos module.
    r�billable�non_billablerE)	rrGr?�listr
�primary_features�billable_features�non_billable_featuresr )rS�features_by_licenserKrLr�counted_featuress      r�!_get_wpos_statistics_active_countr]�s����K��-�/�/�K��
�
��(���w�7�7�	���
�5� 1� B�C�C���*�,�,�#�J�u�$5�$G�H�H���
 �N�
2�
2�#�J�u�$5�$K�$K�$M�$M�N�N��7��&�(�(�	��1��K���r+c��	t��}n@#t$r3}t�dt	|����Yd}~dSd}~wwxYw|jS)z0
    Obtains admin`s options, e.g show_icon
    z$Error when getting admin options: %sNi���)rrr�errorr�	show_icon)�optionsrs  r�is_accelerate_wp_icon_enabledrb�sf���)�+�+���������
�
�<�c�!�f�f�E�E�E��s�s�s�s�s�����������s��
A�(A	�	Ac�>�	ttd��5}|���}ddd��n#1swxYwYn#t$rYdSwxYw	t	j|��}n2#tjtf$rtj	d|��YdSwxYw|S)zE
    Reads whmcs statistics file and returns data as dictionary.
    �rNzMalformed whmcs data: %s)
�openr�read�FileNotFoundError�json�loads�JSONDecodeError�
ValueError�loggingr_)�f�raw_data�datas   r�_read_whmcs_statisticsrp�s����
�)�3�
/�
/�	 �1��v�v�x�x�H�	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 ��������t�t�������z�(�#�#����� �*�-�����
�0�(�;�;�;��t�t������Ks?�A�8�A�<�A�<�A�
A�A�A+�++B�Bc��tj�d��}t��}dddd�}t	��}t��\}}idt
���dt
���dt
���d	t
���d
t
���dt
���d|�d
|�d|�d|�dtt|j	�����dtt|j
�����dtj|j
tj|ji�d|�|j���d|�|j���d|�|j���d|�|j���dt+��i�}t-t.dd���|dd<t-t.dd���|d
d<t-t.d��|d	d<t.D]|}|dkrd}n|}t-|gdd���|d|<t-|gdd���|d
|<t-|gd��|d	|<t-|gddd���|d|<�}t-dgdtjg� ��|dd!<t-dgdtjgd�"��|d
d!<t-dgdtjg� ��|d	d!<t-dgdtjgdd�#��|dd!<t0D]�}	|	d$krd%}n|	}t-gd|	g� ��|d|<t3|	��|d|<|	tjkr:t3|	d&�'��|d|�d(�<t3|	d)�'��|d|�d*�<��t5|gd+�dd!��|S),zj
    Returns current statistics with enabled sites/allowed users counters
    per module and in total
    z/var/lve/enable-wpos.flag�disabled�enabled�none)TFN�
allowed_usersr>�enabled_suites�
visible_users�
enabled_sites�
enabled_users�is_accelerate_wp_flag_enabledrb�1accelerate_wp_suite_enabled_premium_suite_visible�4accelerate_wp_suite_enabled_premium_suite_disallowed�features_visible_by_default�features_allowed_by_default�upgrade_urls�%is_smart_advice_notifications_enabled�+is_smart_advice_plugin_installation_enabled�!is_smart_advice_reminders_enabled�is_object_cache_banners_enabled�whmcsr@T)rI�totalrF�cdn�cdn_free)rIrJ)rC�cdn_pro)rCrI)rCrIrJ�accelerate_wp_cdn�accelerate_wp_cdn_freerU)r[�	_billablerV�
_non_billable)rvrxry)�os�path�isfilerbrrR�dict�sortedrW�visible_features�allowed_featuresr�name�upgrade_urlr�upgrade_url_cdn�get�"disable_smart_advice_notifications�%disable_smart_advice_wordpress_plugin�disable_smart_advice_reminders�disable_object_cache_bannersrprMrr
r]�#_mutually_exclusive_wpos_statistics)
�is_feature_flag�is_feature_icon_enabled�disabled_status�server_wide_options�awp_enabled_visible_premium�awp_enabled_disallowed_premium�result�module�stats_suiterSs
          r�fill_current_wpos_statisticsr��s���g�n�n�%@�A�A�O�;�=�=��'�	��H�H�O�1�3�3��	3�4�4�@��!?�*�����*�
	�$�&�&�*�	�$�&�&�*�	����*�&	����'*�.	����/*�6	(��7*�8	(�)@�9*�:	<�=X�;*�<	?�@^�=*�>	&�v�d�3F�3W�.X�.X�'Y�'Y�?*�@	&�v�d�3F�3W�.X�.X�'Y�'Y�A*�B	���2�>���1�A�
�C*�J	0��1D�1D�EX�E{�1|�1|�K*�L	6��7J�7J�K^�LE�8F�8F�M*�N	,�_�-@�-@�AT�As�-t�-t�O*�P	*�?�+>�+>�?R�?o�+p�+p�Q*�R	�'�)�)�S*�*�F�X(H�!�9��(G�(G�(G�F�?��G�$�'G�!�9��(G�(G�(G�F�?��G�$�'G�!�9�(.�(.�F�?��G�$�,�I�I���U�?�?�$�K�K� �K�/O�
�H�i�D�0:�0:�0:�����,�/O�
�H�i�D�0:�0:�0:�����,�/O�
�H�i�0!�0!�����,�/O�
�H�i�D�4�0I�0I�0I�����,�,�*J�	���{�/?�.@�*B�*B�*B�F�?��I�&�)I�	���{�/?�.@�UY�*[�*[�*[�F�?��I�&�)I�	���{�/?�.@�*B�*B�*B�F�?��I�&�)I�	���{�/?�.@�UY�dh�*j�*j�*j�F�?��I�&��]�]���'�'�'�2�K�K��K�
-�R��u�g�V�V�V�	�� ��-�
.�e�4�4�	�� ��-��L�%�%�%�
.�e��T�T�T�
�#�$��%>�%>�%>�?�2�%�^�\�\�\�
�#�$��%B�%B�%B�C��(��<�<�<���	����Mr+�wpos_statistics�statistic_keys�	from_stat�
subtract_statc��d|��}d|��}|���D][\}}||vrRt|��tur<||vr||vr||xx||zcc<||vr||vr||xx||zcc<�\dS)z/
    Returns mutually exclusive statistics
    �accelerate_wp_N)�items�typer�)r�r�r�r��
from_stat_awp�subtract_awp�key�stats        rr�r�Ds���
1�Y�0�0�M�3�M�3�3�L�$�*�*�,�,�:�:�	��T��.� � �T�$�Z�Z�4�%7�%7��D� � �]�d�%:�%:��Y����4�
�#6�6������$�$���)=�)=��]�#�#�#�t�L�'9�9�#�#�#��
:�:r+)r@FNFr$),rhrlr�r,�typingr�clcommonr�clcommon.clpwdr�clwpos.constantsr�clwpos.logsetupr�clwpos.optimization_featuresr�clwpos.feature_suitesr	r
rrr
r�clwpos.utilsr�clwpos.user.configrrrr�intr r3r9r?rMrRr]rbrpr�r�rWr�r%r+r�<module>r�s�����������
�	�	�	�
�
�
�
�������������*�*�*�*�*�*�4�4�4�4�4�4�)�)�)�)�)�)�B�B�B�B�B�B�����������������1�0�0�0�0�0�)�)�)�)�)�)�-�-�-�-�-�-�
�-�+�
,�
,��
�s�
�T�RU�Y�
�[^�
�
�
�
� 
X�S�
X�4��9�
X��
X�
X�
X�
X�
X�S�
X�4��9�
X��
X�
X�
X�
X�L�C�L��c��L�s�L�L�L�L�� �'+�� � ��c�� �� � ��9�	 � � � �F/�/�/�0��S�����.	�	�	����(y�y�y�x:��:�t�:�`c�:�tw�:�:�:�:�:�:r+

Zerion Mini Shell 1.0