Edit File: notifications_helper.cpython-311.pyc
� L( e� � �f � d dl mZ d dlZd dlZd dlZd dlZd dlmZmZm Z dZ G d� de� � ZdS )� )�absolute_importN)�Dict�Union�IterablezAleksandr Shyshatskyc �r � e Zd ZdZdZdZd� Zd� Zd� Zd� Z d� Z ed � � � Zd � Z d� Zd� Zd � Zd� Zd� ZdS )�NotificationsHelperzb Helper for our StatsNotifier plugin, contains logic related to notification periods z/var/lve/statsnotifier_last.tsz%/var/lve/statsnotifier_timestamps.binc � � i | _ i | _ d| _ t j t � � | _ | � � � d S )N���)�_users_notification_info�_resellers_notification_info�_admin_notify_time�logging� getLogger�__name__�_log�_load_from_persistent_storage��selfs ��/builddir/build/BUILDROOT/lve-stats-4.2.1-1.el8.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/lib/notifications_helper.py�__init__zNotificationsHelper.__init__ sF � �(*��%�,.��)�"$����%�h�/�/�� � �*�*�,�,�,�,�,� c � � | � � � | _ t j � | j � � sdS t | j d� � 5 }t j |� � \ | _ | _ ddd� � dS # 1 swxY w Y dS # t t f$ r | j � d� � Y dS w xY w)z� Load information about periods from persistent storage. Admin timestamp contains in separate file, in order to make it backwards-compatible with old logic N�rbz(Cannot load data from persistent storage)�_read_ts_from_filer �os�path�exists�RESELLERS_NOTIFICATIONS_STORAGE�open�pickle�loadr r �IOError�EOFErrorr � exception�r �fs r r z1NotificationsHelper._load_from_persistent_storage% s# � � #'�"9�"9�";�";����w�~�~�d�B�C�C� ��F� M��d�:�D�A�A� b�Q�SY�S^�_`�Sa�Sa�P��-�t�/P� b� b� b� b� b� b� b� b� b� b� b� b���� b� b� b� b� b� b����"� M� M� M��I��� K�L�L�L�L�L�L� M���s6 �B �"B�8B �B � B �B � B �+C� Cc �4 � | � | j � � t | j d� � 5 }t j | j | j f|d�� � ddd� � dS # 1 swxY w Y dS # t $ r | j � d� � Y dS w xY w)z� Save information about periods on disk. Admin timestamp contains in separate file, plain text. Resellers info is pickle'd and saved into other file. �wb� )�protocolNz+Unable to save resellers timestamps to file)�_save_ts_to_filer r r r �dumpr r r"