관리-도구
편집 파일: utils.cpython-311.opt-1.pyc
� IMg� � � � d dl Z d dlmZ d dlmZmZ d dlmZ d dlm Z d dl mZ d dlm Z dd lmZ e j e� � Zd ededed efd�Zdedee dedee fd�Zdedefd�Zdee d efd�Zd� ZdS )� N)�chain)�List�Any)�hooks)�FeatureManagementPerms)�instance)�execute_iterable_expression� )�features�user�feature�value�returnc � � K � t j � � � 5 }t j | � � }|� ||� � t j |� � } || |� � }|rt � d||| � � n1t � d||| � � |� � � |cddd� � S # 1 swxY w Y dS )z�Sets a `feature` to `value` for a given `user`. Calls appropriate hook and returns its (bool) result. Logs the result of setting change. If hook fails rollbacks changes to database. z!Applied setting %s=%s for user %sz)Failed to apply setting %s=%s for user %sN)r �db�atomicr �get_perm�set_featurer �get_hook�logger�info�error�rollback)r r r �trx�perm�hook�oks �]/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/feature_management/utils.pyr r s% � � � � �� � � � � ��%�.�t�4�4������%�(�(�(��~�g�&�&�� �T�$�� � �� � ��K�K�3�W�e�T� � � � � �L�L�;���� � � � �L�L�N�N�N��#� � � � � � � � � � � ���� � � � � � s �BC�C�C�users�existing_usersc � � K � g g d�}|D ]p}||vrt � d|� � �"t || |� � � d {V ��r|d � |� � �U|d � |� � �q|S )N)� succeeded�failedzNo such user: %sr"