관리-도구
편집 파일: api.cpython-311.pyc
� IMg� � � � d Z ddlZddlZddlmZ ddlmZmZmZ ddl m Z mZmZ ddl mZ ej e� � Zd� Z ee de� � � d � � � Zdeeee f fd�Zdeeee f fd �Zdeeeeef f fd�Zdee fd�Zdee fd�Zdefd�Zdefd�Zdee fd�Zd� ZdS )z/Gather information from Plesk via DB querries. � N)�defaultdict)�Dict�List�Sequence)� CheckRunError� check_run�retry_on��PanelExceptionc � � K � t | i |���)Nr )�args�kwargss �\/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/subsys/panels/plesk/api.py�raise_panel_exceptionr s � � � � �$� )�&� )� )�)� � )� max_tries�on_errorc � �^ K � t dddd| g� � � d {V ��� � � S )N�plesk�dbz-Nz-e)r �decode��querys r � _run_queryr s= � � � ��W�d�D�$��>�?�?�?�?�?�?�?�?�G�G�I�I�Ir �returnc � � K � t d� � � d{V ��� � � } t t � � }t | ddd� | ddd� � � D ]&\ }}|dk r|| � |� � �'|S )z'Return mapping: user -> user's domains.z�select login, name from domains left join hosting on dom_id = domains.id right join sys_users on hosting.sys_user_id = sys_users.idNr � � �NULL)r �splitr �list�zip�append)�result�result_mapping�user�domains r �get_user_to_domainr) s� � � � � � L� � � � � � � � � �e�g�g� � !��&�&�N��F�1�4�a�4�L�&���A��,�7�7� 0� 0���f��V����4� �'�'��/�/�/���r c � � K � t d� � � d{V ��� � � } d� t | ddd� | ddd� � � D � � S )zReturn mapping: domain -> user.z�select name, login from domains left join hosting on dom_id = domains.id left join sys_users on hosting.sys_user_id = sys_users.idNc � � i | ] \ }}||g�� S � r, )�.0r( r'