CasperSecurity

Current Path : /lib/python3/dist-packages/certbot/plugins/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/certbot/plugins/__pycache__/storage.cpython-310.pyc

o

6��aB�@sldZddlZddlZddlmZddlmZddlmZddlm	Z	ddlm
Z
e�e�Z
Gdd	�d	�ZdS)
zPlugin storage class.�N)�Any)�Dict)�errors)�
filesystem)�osc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�
PluginStoragez4Class implementing storage functionality for pluginscCs||_||_d|_||dS)z�Initializes PluginStorage object storing required configuration
        options.

        :param .configuration.NamespaceConfig config: Configuration object
        :param str classkey: class name to use as root key in storage file

        FN)�_config�	_classkey�_initialized)�self�config�classkey�r�9/usr/lib/python3/dist-packages/certbot/plugins/storage.py�__init__s
	zPluginStorage.__init__cCs&tj�|jjd�|_|��d|_dS)zhInitializes PluginStorage data and reads current state from the disk
        if the storage json exists.z.pluginstorage.jsonTN)r�path�joinr�
config_dir�_storagepath�_loadr
)rrrr�_initialize_storage s
z!PluginStorage._initialize_storagec
Cs�i}d}zt|jd��}|��}Wd�n1swYWn,tyL}z d�|jt|��}tj�|j�rBt	�
|�t�|��WYd}~nd}~wwzt
�|�}Wn#tyw|set	�d|j�nd�|j�}t	�
|�t�|��Ynw||_dS)z�Reads PluginStorage content from the disk to a dict structure

        :raises .errors.PluginStorageError: when unable to open or read the file
        ��rNz1Could not read PluginStorage data file: {0} : {1}z2Plugin storage file %s was empty, no values loadedz$PluginStorage file {0} is corrupted.)�openr�read�IOError�format�strrr�isfile�logger�errorr�PluginStorageError�json�loads�
ValueError�debug�_data)r�data�filedata�fh�e�errmsgrrrr(s@
��
�

�����

��
	zPluginStorage._loadc
Cs|jsd}t�|�t�|��zt�|j�}Wnty4}zd�	t
|��}t�|�t�|��d}~wwz-t�t
�|jtjtjBtjBd�d��}|�|�Wd�WdS1s[wYWdSty�}zd�	|jt
|��}t�|�t�|��d}~ww)z�Saves PluginStorage content to disk

        :raises .errors.PluginStorageError: when unable to serialize the data
            or write it to the filesystem
        z;Unable to save, no values have been added to PluginStorage.z+Could not serialize PluginStorage data: {0}Ni��wz4Could not write PluginStorage data to file {0} : {1})r
rr rr!r"�dumpsr&�	TypeErrorrrr�fdopenrrr�O_WRONLY�O_CREAT�O_TRUNC�writer)rr+�
serializedr*r)rrr�saveFsB

�

����&�
�

��zPluginStorage.savecCs:|js|��|j|jvri|j|j<||j|j|<dS)z�Put configuration value to PluginStorage

        :param str key: Key to store the value to
        :param value: Data to store
        N)r
rr	r&)r�key�valuerrr�putds
zPluginStorage.putcCs|js|��|j|j|S)z�Get configuration value from PluginStorage

        :param str key: Key to get value from the storage

        :raises KeyError: If the key doesn't exist in the storage
        )r
rr&r	)rr6rrr�fetchqszPluginStorage.fetchN)
�__name__�
__module__�__qualname__�__doc__rrrr5r8r9rrrrrs
r)r=r"�logging�typingrr�certbotr�certbot.compatrr�	getLoggerr:rrrrrr�<module>s

Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY