ok

Mini Shell

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

�

�2�fx'����dZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
ddlmZddl
mZddlmZmZddlmZdd	lmZdd
lmZmZddlmZmZmZddlmZm Z m!Z!m"Z"dd
l#m$Z$m%Z%ddl&m'Z(m)Z)m*Z*m+Z+m,Z,m-Z-Gd�de
��Z.de/dee.fd�Z0Gd�de.��Z1dee1fd�Z2de3fd�Z'de/de/dee3fd�Z4de/fd�Z5de/de/dee3fd�Z6de/de/dee3fd�Z7de/de/dee/fd�Z8d�Z9de/fd �Z:d!ej;fd"�Z<d#�Z=de/fd$�Z>de/de/de$fd%�Z?de/de/fd&�Z@de/de/fd'�ZAde/dee3fd(�ZBdee3fd)�ZCdee3fd*�ZDdee3fd+�ZEdS),ah
This module is the only one that is allowed to be
imported from other tools. Please, keep list of "external"
methods here, so we can keep them backwards-compatible.

The purpose is to reduce number of places in code which randomly
are dependencies of other tools (e.g. x-ray).

Don't user this module in clwpos code.

Maybe one day we will make proper api :)
�N)�List�Optional)�	TypedDict��get_or_create_unique_identifier)�	WposError)�SMART_ADVISE_USER_UTILITY�WPOS_DAEMON_SOCKET_FILE)�
WposDaemon)�php_info)�PremiumSuite�CDNSuitePro)�get_visible_modules�get_allowed_modules�get_allowed_features_dict)�Feature�OBJECT_CACHE_FEATURE�CDN_FEATURE�!convert_feature_list_to_interface)�LicenseApproveStatus�
UserConfig)�is_wpos_supported�daemon_communicate�drop_permissions_if_needed�get_subscription_status�run_in_cagefs_if_needed�get_server_wide_optionsc�B�eZdZUeed<eed<eed<eed<eed<dS)�HostInfo�vhost�account�version�handler�documentrootN��__name__�
__module__�__qualname__�str�__annotations__���B/opt/cloudlinux/venv/lib64/python3.11/site-packages/clwpos/papi.pyrr)sB��������J�J�J�
�L�L�L�
�L�L�L�
�L�L�L������r,r�user�returnc�*�tj|��S)a&
    Get information about vhosts in the following format:
    [
        {
            'vhost': 'username.zone',
            'account': 'username',
            'version': 'ea-php80',
            'handler': 'php-fpm',
            'documentroot': '/home/username/public_html'
        }
    ]
    )r�_php_get_vhost_versions)r.s r-�php_get_vhost_versionsr21s���-�d�3�3�3r,c��eZdZUeed<dS)�HostInfoExtended�
php_binaryNr%r+r,r-r4r4As��������O�O�O�O�Or,r4c�6�t��}d�|D��S)a
    Get information about vhosts in the following format:
    [
        {
            'vhost': 'username.zone',
            'account': 'username',
            'version': 'ea-php80',
            'php_binary': '/opt/php/php',
            'handler': 'php-fpm',
            'documentroot': '/home/username/public_html'
        }
    ]
    Unlike the php_get_vhost_versions, it automatically detects
    current user and also performs php version change inside the cagefs,
    providing additional information about php binary.
    c��g|]E}t|d|d|dj|dj|d|d�����FS)r r!r"r#r$)r r!r"r5r#r$)r4�
identifier�bin)�.0�php_datas  r-�
<listcomp>z/php_get_vhost_versions_user.<locals>.<listcomp>Wso��	�	�	��	��7�#��Y�'��Y�'�2��	�*�.��Y�'�!�.�1�
	
�	
�	
�	�	�	r,)�	_php_info)�results r-�php_get_vhost_versions_userr?Es0��"�[�[�F�	�	�!�	�	�	�	r,c��t��S)zE
    Determines whether wpos is supported in current environment
    )�_is_wpos_supportedr+r,r-rrcs�����r,�feature�usernamec��	tj|��}n#t$rYdSwxYwt|��jd�t|j���D��vS)z�
    Determines whether feature is visible for username.
    Return False in case if feature is unknown.
    Return None in case if user is missing.
    Nc3�$K�|]}|jV��dS�N��NAME�r:�items  r-�	<genexpr>z%is_feature_visible.<locals>.<genexpr>u�5����%�%���	�%�%�%�%�%�%r,��uid)�pwd�getpwnam�KeyErrorrrHr�pw_uid�rBrC�pws   r-�is_feature_visiblerUj�}���
�\�(�
#�
#���������t�t������7��� �%�%�1�b�i�@�@�@�%�%�%�����
%�%c�j�t|�����t��jvSrF)r�optimization_featurer�hidden_features)rBs r-�is_feature_hidden_server_wider[zs+���7���0�0�2�2�6M�6O�6O�6_�_�_r,c��	tj|��}n#t$rYdSwxYwt|��jd�t|j���D��vS)z�
    Determines whether feature is allowed for username to be activated.
    Return False in case if feature is unknown.
    Return None in case if user is missing.
    Nc3�$K�|]}|jV��dSrFrGrIs  r-rKz%is_feature_allowed.<locals>.<genexpr>�rLr,rM)rOrPrQrrHrrRrSs   r-�is_feature_allowedr^~rVrWc���	tj|��}n#t$rYdSwxYw	ttj||jd���d}n#t$rYdSwxYw|S)�M
    Determines whether feature is allowed for username to be activated.
    N)�commandrBrN�pendingF)rOrPrQrr�!DAEMON_GET_UPGRADE_ATTEMPT_STATUSrRr)rBrCrT�
is_pendings    r-�is_subscription_pendingre�s����
�\�(�
#�
#���������t�t������'�!�C���9�)
�)
����	�
�
��
�����u�u���������
%�%�(A�
A �A c���	tj|��}n#t$rYdSwxYw	ttj|j|d���d}n#t$rYdSwxYw|S)r`N)rarNrB�upgrade_url)rOrPrQrr�DAEMON_GET_UPGRADE_LINK_COMMANDrRr)rBrCrTrhs    r-�get_subscription_upgrade_urlrj�s����
�\�(�
#�
#���������t�t������(�!�A��9��*
�*
����	����
�����t�t������rfc��t|��5tdg}t|d���j}	t	j|��dcddd��S#t$rtjd||����wxYw#1swxYwYdS)zWrapper for easy mockingz
get-cdn-usageT)�check�dataNr)�
returncode�cmd�output)	rr	r�stdout�json�loadsrQ�
subprocess�CalledProcessError)rC�get_usage_commandrps   r-�_get_cdn_usage_statisticsrw�s���	#�H�	-�	-�	�	�6��H��(�):�$�G�G�G�N��	��:�f�%�%�f�-�	�	�	�	�	�	�	�	���	�	�	��/��"3�����
�	����
	�	�	�	����	�	�	�	�	�	s"� A<�A�"A9�9A<�<B�Bc��	tj|��}n'#t$rtjd|��icYSwxYwt|��S)zf
    Backwards compatibility for the third party tools.
    Use get_subscriptions_info_2 instead.
    z<Cannot get uid for user: %s, subscription info will be empty)rOrP�	Exception�logging�error�get_subscriptions_by_pw)rC�user_pws  r-�get_subscriptions_infor~�s`��
��,�x�(�(���������
�T�V^�_�_�_��	�	�	�����#�7�+�+�+s��!;�;r}c	��i}t|j��}d�|���D��}tjt
jftjtjffD]�\}}tt|||��������x||���<}|tjkr�d}t|���|j
��r`	t|j
��}t|��}n;#t $r.}	t#jdt'|	����d}Yd}	~	nd}	~	wwxYw||d<��|S)Nc�4�i|]\}}|t|����Sr+)r)r:�feature_set�featuress   r-�
<dictcomp>z+get_subscriptions_by_pw.<locals>.<dictcomp>�s>��"^�"^�"^�&;�k�8�#.�/P�QY�/Z�/Z�"^�"^�"^r,)�statusz'Error during obtaining usage, error: %s�usage)rrR�itemsrrHr
�namerr�dictr�lowerr^�pw_namerw�calculate_cdn_usageryrz�warningr))
r}�
subscriptions�allowed_features_dict�converted_allowed_featuresrB�
suite_name�subscriptionr��info�es
          r-r|r|�sv���M�5�g�n�E�E��"^�"^�?T�?Z�?Z�?\�?\�"^�"^�"^��"�
&��(9�:�
�
�{�/�0� �*�*����9=�*�*�J��
�
���I�I�9
�9
�9
�	
�
�g�m�m�o�o�&��
�k�&�&�&��E�!�'�-�-�/�/�7�?�C�C�
6�6�4�W�_�E�E�D�
0��5�5�E�E��	!�!�!�!��O�$M�s�ST�v�v�V�V�V� �E�E�E�E�E�E�����!����%*�L��!���s�,D�
E�$E�Ec��|d|dkrd|ddz�d�nd}|d}|d}|dks|dkrd}||d�|d�}|S)	N�total_bytes_used�limit_bytesz0Content Delivery Network: You have reached your i@z+GB limit. Please upgrade your subscription.r)r��limit)�	bandwidthr�r+)r�r��
bytes_used�bytes_limitr�s     r-r�r��s����,�-��m�1D�D�D���m�$�	�1�����KO���(�)�J��}�%�K��Q���+��*�*��� � �
�
��
�
�E��Lr,c� �t|��S)zl
    Reads configuration and gets identifier of user that
    he can use to auth on provisioning server
    r)rCs r-�get_user_auth_keyr�s��
+�8�4�4�4r,c��t|��5t|��}t|��}|�|��cddd��S#1swxYwYdS)z_
    Provides easy way for 3rd party tools to get information about license approve status
    N)rrr�get_license_approve_status�rBrC�ucs   r-r�r�s���
$�H�	-�	-�6�6�
��
!�
!���'�"�"���,�,�W�5�5�	6�6�6�6�6�6�6�6�6�6�6�6����6�6�6�6�6�6s�3A�A�Ac��t|��5t|��}t|��}|�|��ddd��dS#1swxYwYdS)zB
    Provides easy way for 3rd party tools to approve license
    N)rrr�approve_license_agreementr�s   r-r�r�s���
$�H�	-�	-�.�.�
��
!�
!���'�"�"��
�$�$�W�-�-�-�	.�.�.�.�.�.�.�.�.�.�.�.����.�.�.�.�.�.s�4A�A�Ac���t|��5t|��}|js	ddd��dSt|j�����cddd��S#1swxYwYdS)z�
    Returns text of the license agreement for the given feature or None
    if feature is not required to approve agreement
    N)rr�HAS_LICENSE_TERMS�open�LICENSE_TERMS_PATH�read)rBrCs  r-�get_license_agreement_textr�&s���

$�H�	-�	-�7�7��'�"�"���(�	��	7�7�7�7�7�7�7�7�
�G�.�/�/�4�4�6�6�7�7�7�7�7�7�7�7�7�7�7�7����7�7�7�7�7�7s�A'�%A'�'A+�.A+c��	tj|��}n#t$rYdSwxYwtt	|j�����S)z^
    Determines whether at least one feature is
    allowed for username to be activated.
    NrM)rOrPrQ�boolrrR)rCrTs  r-�is_wpos_visibler�3sX��
�
�\�(�
#�
#���������t�t������#��	�2�2�2�3�3�3rWc�(�t��jS)zK
    Returns whether WordPress SmartAdvice notifications are disabled.
    )r�"disable_smart_advice_notificationsr+r,r-�2is_smart_advice_notifications_disabled_server_wider�@s��#�$�$�G�Gr,c�(�t��jS)zR
    Returns whether WordPress SmartAdvice plugin is disabled on this server.
    )r�%disable_smart_advice_wordpress_pluginr+r,r-�5is_smart_advice_wordpress_plugin_disabled_server_wider�Gs��#�$�$�J�Jr,c�(�t��jSrF)r�disable_smart_advice_remindersr+r,r-�.is_smart_advice_reminders_disabled_server_wider�Ns��"�$�$�C�Cr,)F�__doc__rrrz�osrOrt�typingrr�typing_extensionsr�clwpos.billingr�clwpos.cl_wpos_exceptionsr�clwpos.constantsr	r
�
clwpos.daemonr�clwpos.data_collector_utilsrr=�clwpos.feature_suitesr
r�$clwpos.feature_suites.configurationsrrr�clwpos.optimization_featuresrrrr�clwpos.user.configrr�clwpos.utilsrrArrrrrrr)r2r4r?r�rUr[r^rerjrwr~�
struct_passwdr|r�r�r�r�r�r�r�r�r�r+r,r-�<module>r�s�������������	�	�	�	�
�
�
�
�����!�!�!�!�!�!�!�!�'�'�'�'�'�'�:�:�:�:�:�:�/�/�/�/�/�/�O�O�O�O�O�O�O�O�$�$�$�$�$�$�=�=�=�=�=�=�;�;�;�;�;�;�;�;�t�t�t�t�t�t�t�t�t�t�v�v�v�v�v�v�v�v�v�v�v�v�?�?�?�?�?�?�?�?����������������������y����
4��
4��h��
4�
4�
4�
4� �����x�����T�*:�%;�����< �4� � � � �
��
�s�
�x��~�
�
�
�
� `�3�`�`�`�`�
��
�s�
�x��~�
�
�
�
� �S��C��H�T�N�����*�#�����#������(���,�S�,�,�,�,��S�%6�����>���,5��5�5�5�5�6��6�s�6�?S�6�6�6�6�.�s�.�c�.�.�.�.�
7��
7�s�
7�
7�
7�
7�
4�c�
4�h�t�n�
4�
4�
4�
4�H�H�T�N�H�H�H�H�K�x��~�K�K�K�K�D����D�D�D�D�D�Dr,

Zerion Mini Shell 1.0