%PDF- %PDF-
Direktori : /lib/python3/dist-packages/certbot/__pycache__/ |
Current File : //lib/python3/dist-packages/certbot/__pycache__/reverter.cpython-312.pyc |
� M/�e5V � �� � d Z ddlZddlZddlZddlZddlZddlZddlmZ ddlm Z ddlm Z ddlmZ ddlmZ ddl mZ dd l mZ dd l mZ ddlmZ ddlmZ dd lmZ ej, e� Z G d� d� Zy)zGReverter class saves configuration checkpoints and allows for recovery.� N)�Iterable)�List)�Set)�TextIO)�Tuple)� configuration)�errors)�util)� constants)� filesystem)�osc �p � e Zd ZdZdej ddfd�Zd!d�Zd"deddfd�Z d e e d eddfd�Zd e e d eddfd�Z d ed e e d eddfd�Zdedeeee f fd�Zd eddfd�Zdeddfd�Zd e e ddfd�Zdededdfd�Zdedee ddfd�Zdedefd�Zd!d�Zdedefd�Zdeddfd�Zdefd�Zd!d �Zy)#�Reverteraq Reverter Class - save and revert configuration checkpoints. This class can be used by the plugins, especially Installers, to undo changes made to the user's system. Modifications to files and commands to do undo actions taken by the plugin should be registered with this class before the action is taken. Once a change has been registered with this class, there are three states the change can be in. First, the change can be a temporary change. This should be used for changes that will soon be reverted, such as config changes for the purpose of solving a challenge. Changes are added to this state through calls to :func:`~add_to_temp_checkpoint` and reverted when :func:`~revert_temporary_config` or :func:`~recovery_routine` is called. The second state a change can be in is in progress. These changes are not temporary, however, they also have not been finalized in a checkpoint. A change must become in progress before it can be finalized. Changes are added to this state through calls to :func:`~add_to_checkpoint` and reverted when :func:`~recovery_routine` is called. The last state a change can be in is finalized in a checkpoint. A change is put into this state by first becoming an in progress change and then calling :func:`~finalize_checkpoint`. Changes in this state can be reverted through calls to :func:`~rollback_checkpoints`. As a final note, creating new files and registering undo commands are handled specially and use the methods :func:`~register_file_creation` and :func:`~register_undo_command` respectively. Both of these methods can be used to create either temporary or in progress changes. .. note:: Consider moving everything over to CSV format. :param config: Configuration. :type config: :class:`certbot.configuration.NamespaceConfig` �config�returnNc � � || _ t j |j t j | j j � y )N)r r �make_or_verify_dir� backup_dirr �CONFIG_DIRS_MODE�strict_permissions)�selfr s �2/usr/lib/python3/dist-packages/certbot/reverter.py�__init__zReverter.__init__B s5 � ����������y�9�9�4�;�;�;Y�;Y� [� c �d � t j j | j j � r' | j | j j � yy# t j $ r@ t j d| j j � t j d� �w xY w)a Reload users original configuration files after a temporary save. This function should reinstall the users original configuration files for all saves with temporary=True :raises .ReverterError: when unable to revert config z$Incomplete or failed recovery for %sz!Unable to revert temporary configN) r �path�isdirr �temp_checkpoint_dir�_recover_checkpointr � ReverterError�logger�critical�r s r �revert_temporary_configz Reverter.revert_temporary_configH s� � � �7�7�=�=����8�8�9� P��(�(����)H�)H�I� :�� �'�'� P����:��K�K�3�3�� �*�*�+N�O�O� P�s �%A �AB/�rollbackc �> � t |� }|dk r*t j d� t j d� �t j | j j � }|j � |st j d� n.t |� |k r t j d|t |� � |dkD rf|rct j j | j j |j � � } | j! |� |dz }|dkD r|r�ay y y y # t $ r+ t j d� t j d� �w xY w# t j $ r+ t j# d� t j d� �w xY w) ay Revert 'rollback' number of configuration checkpoints. :param int rollback: Number of checkpoints to reverse. A str num will be cast to an integer. So "2" is also acceptable. :raises .ReverterError: if there is a problem with the input or if the function is unable to correctly revert the configuration checkpoints z,Rollback argument must be a positive integerz Invalid Inputr zHCertbot hasn't modified your configuration, so rollback isn't available.z0Unable to rollback %d checkpoints, only %d existz)Failed to load checkpoint during rollbackz)Unable to load checkpoint during rollback� N)�int� ValueErrorr! �errorr r r �listdirr r �sort�warning�lenr �join�popr r"