AlkantarClanX12

Your IP : 18.118.226.167


Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/wmt/common/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/wmt/common/__pycache__/config.cpython-311.pyc

�

 tf2����ddlZddlZddlZddlmZmZmZddlmZm	Z	ddl
mZddlm
Z
ddlmZddlmZddlmZeGd	�d
����ZGd�d��ZdS)
�N)�	dataclass�asdict�field)�CONFIG_PATH�PING_CONNECTIONS)�WmtConfigException)�parse)�get_admin_email)�gethostname)�Listc��eZdZUdZdZeed<dZeed<eZ	eed<dZ
eed<d	Zeed
<e
e���Zeeed<d
Zeed<dZeed<dS)�CfgzC
    Default values, in case config has not been specified yet
    ��
ping_interval�
�ping_timeout�ping_connectionsN�report_email��
report_top)�default_factory�ignore_listT�summary_notification_enabledF�alert_notifications_enabled)�__name__�
__module__�__qualname__�__doc__r�int�__annotations__rrrr�strrr�listrrr�boolr����/builddir/build/BUILDROOT/cl-web-monitoring-tool-3.1.3-1.el8.cloudlinux.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/wmt/common/config.pyrrs�����������M�3�����L�#����,��c�,�,�,��L�#�����J�����"�U�4�8�8�8�K��c��8�8�8�)-� �$�-�-�-�(-���-�-�-�-�-r%rc��eZdZd�Zd�Zd�Zdefd�Zed���Z	de
fd�Zed	���Zd
�Z
defd�Zdefd�Zd
S)�
ConfigManagerc�4�tj���|_dt	����|_t
��|_|���|_	|�
��|_|���|_
dS)Nzweb-monitoring-tool@)r�__dataclass_fields__�keys�allowed_paramsr�
from_emailr
�default_report_email�	_init_cfg�cfg�generate_ignored_domains�_ignored_domains�_get_target_email�target_email��selfs r&�__init__zConfigManager.__init__s{��!�6�;�;�=�=���@����@�@���$3�$5�$5��!��>�>�#�#���!%� =� =� ?� ?��� �2�2�4�4����r%c�@�|jjr|jjn|jS)a
        This function checks to see which email address to use for TO: field of smtp.
        If report_email has been defined by user then report_email will be used.
        By default (in case not defined by user) default_report_email will be used
        )r0rr.r5s r&r3zConfigManager._get_target_email)s!��)-��(=�\�t�x�$�$�4�C\�\r%c�*�t|j��S�N)rr0r5s r&�to_dictzConfigManager.to_dict1s���d�h���r%�returnc	�P�|���st��S|���}t��}|���D]L\}}||jvr-tjd|�dt|j�������;t|||���M|S)Nzunsupported parameter "z:", please ensure config contains only allowed parameters: )	�
is_presentr�read�itemsr,�logging�warningr"�setattr)r6�datar0�key�values     r&r/zConfigManager._init_cfg4s������ � �	��5�5�L��y�y�{�{���e�e���*�*�,�,�	)�	)�J�C���$�-�-�-���M�c�M�M�15�d�6I�1J�1J�M�M�����
��S�%�(�(�(�(��
r%c�J�tj�t��Sr:)�os�path�isfilerr$r%r&r>zConfigManager.is_presentGs���w�~�~�k�*�*�*r%�new_jsonc��	tj|��}n3#tj$r!}tt	|�����d}~wwxYwt|������|j��s$tdt|j�������i|�
���|�}|�d��rFt|�d��t��r|d�
d��|d<ttd��5}tj||d���ddd��n#1swxYwYt#di|��|_|�
��S)	z�
        Changes configuration of wmt

        Returns:
            self.to_dict()

        Raises:
            WmtConfigException

        Example:
            wmt-api-solo --config-change {'key': 'val'}
        Nz@some of passed params are unsupported, only allowed parameters: r�,�wr)�indentr$)�json�loads�JSONDecodeErrorrr!�setr+�issubsetr,r"r;�get�
isinstance�split�openr�dumprr0)r6rK�
new_config�e�config�fs      r&�modifyzConfigManager.modifyKs���	-���H�-�-�J�J���#�	-�	-�	-�$�S��V�V�,�,�,�����	-�����:�?�?�$�$�%�%�.�.�t�/B�C�C�	^�$�&]�AE�d�FY�AZ�AZ�&]�&]�^�^�
^�
��l�l�n�n�
��
��
�:�:�m�$�$�	E��F�J�J�}�4M�4M�s�)S�)S�	E�$*�=�$9�$?�$?��$D�$D�F�=�!��+�s�
#�
#�	+�q��I�f�a��*�*�*�*�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+��=�=��=�=����|�|�~�~�s&��A�A�A�/E�E�Ec���	tt��5}tj|��}ddd��n#1swxYwYn3#tj$r!}tt
|�����d}~wwxYw|Sr:)rXrrP�loadrRrr!)r]rDr[s   r&r?zConfigManager.reados���	-��k�"�"�
$�a��y��|�|��
$�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$����
$�
$�
$�
$����#�	-�	-�	-�$�S��V�V�,�,�,�����	-�����s2�A�7�A�;�A�;�A�A3�A.�.A3c�8�|���|_dSr:)r/r0r5s r&�reloadzConfigManager.reloadxs���>�>�#�#����r%c��||jvS)z5
        Check if domain is in ignored list.
        )r2)r6�domains  r&�is_domain_ignoredzConfigManager.is_domain_ignored{s����.�.�.r%c��t��}|jjD]@}t|��}d|vr|�dd��}|�|���A|S)al
        Generates ignored domains from self.ignore_list and
        returns it for using as cache in self.ignored_domains set().

        Purpose of this function is to generate formatted url as "http://www.test.com"
        from user entered urls in self.ignore_list.
        It makes sense to check domains names with this cache before pings or reports
        �https�http)rSr0rr	�replace�add)r6�domains�d�domain_from_ignore_lists    r&r1z&ConfigManager.generate_ignored_domains�sk���%�%����%�	1�	1�A�&+�A�h�h�#��1�1�1�*A�*I�*I�'�SY�*Z�*Z�'��K�K�/�0�0�0�0��r%N)rrrr7r3r;rr/�staticmethodr>r!r^r?rbr#rerSr1r$r%r&r(r(s�������	5�	5�	5�]�]�]� � � ��3�����&�+�+��\�+�"�s�"�"�"�"�H����\��$�$�$�/�4�/�/�/�/��#������r%r()rArHrP�dataclassesrrr�wmt.common.constrr�wmt.common.exceptionsr�wmt.common.url_parserr	�clcommon.cpapir
�socketr�typingrrr(r$r%r&�<module>rvs ������	�	�	�	�����0�0�0�0�0�0�0�0�0�0�:�:�:�:�:�:�:�:�4�4�4�4�4�4�'�'�'�'�'�'�*�*�*�*�*�*��������������.�.�.�.�.�.�.���.�v�v�v�v�v�v�v�v�v�vr%