관리-도구
편집 파일: users_manager.cpython-311.pyc
� �Cg� � �� � d dl Z d dlmZ d dlmZmZmZmZmZ d dl m Z mZ d dlm Z G d� de� � Z G d� d ed g d �� � � � Z G d� de� � Z e� � ZdS ) � N)� namedtuple)�Optional�Dict� Generator�Tuple�List)�cpapi�FormattedException)�funcc � � e Zd ZdS )�UserNotFoundErrorN��__name__� __module__�__qualname__� � ��/builddir/build/BUILDROOT/lve-stats-4.2.10-1.el8.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/lib/commons/users_manager.pyr r � � � � � � ��Dr r c � � e Zd ZdS )�UserNr r r r r r r r r )�username�domain�resellerc �P � e Zd ZdZd� Zd� Zd� Zed� � � Zdd�Z dd�Z d � Zd S )�UsersInfoManagerzB Implements some different functions for user management; c � � i | _ d S )N)�users_cache��selfs r �__init__zUsersInfoManager.__init__ s � �����r c � � t | � |� � � � | _ dS # t j $ r t j d� � Y dS w xY w)z(Cache data from cpapi for given resellerzIControl panel API is not implemented, some features may not work properlyN)�dict�_iter_panel_usersr r �NotSupported�logging�info)r r s r �build_users_cachez"UsersInfoManager.build_users_cache s| � � @�#�D�$:�$:�8�$D�$D�E�E�D������!� @� @� @��L� ?� @� @� @� @� @� @� @���s �'+ �#A�Ac # �n K � | � |� � D ]\ }}}|t |||�� � fV � �d S )N)r r r )�_iter_panel_users_tuplesr )r r �login� reseller_r s r r$ z"UsersInfoManager._iter_panel_users( s[ � � � �(,�(E�(E�h�(O�(O� Q� Q�$�E�9�f���u�y��P�P�P�P�P�P�P�P� Q� Qr c # �� K � | �%t j d�� � D ] \ }}}|||fV � �d S t t j | � � � � � � � D ]\ }}|| |fV � � d S )N)�cploginr �dns)�keyls)r �cpinfo�listr �get_reseller_domains�items)r r+ r, r s r r* z)UsersInfoManager._iter_panel_users_tuples- s� � � � � ��,1�L�?]�,^�,^�,^� /� /�(��y�&��Y��.�.�.�.�.� /� /� "&�d�&?��&I�&I�&O�&O�&Q�&Q�!R�!R� .� .� ��v��X�v�-�-�-�-�-� .� .r Tc � � | j | j S # t $ r"}|rt dd|id�� � |�Y d}~dS d}~ww xY w)zGet domain for userz<An error occurred while getting domain for user %(username)sr ��message�contextN)r r �KeyErrorr �r r � raise_exc�es r � get_domainzUsersInfoManager.get_domain8 sx � � ��#�H�-�4�4��� � � �� ?�'�]� *�H�5�)7� )7� 8� 8�=>�?� �4�4�4�4�4����� ���� � � A �;�A c � � | j | j S # t $ r"}|rt dd|id�� � |�Y d}~dS d}~ww xY w)zGet reseller for userz>An error occurred while getting reseller for user %(username)sr r6 N)r r r9 r r: s r �get_resellerzUsersInfoManager.get_resellerD sx � � ��#�H�-�6�6��� � � �� ?�'�_� *�H�5�)7� )7� 8� 8�=>�?� �4�4�4�4�4����� ���r>