U
    ÝÁ]r  ã                   @   sx   d Z ddlZddlmZ ddlmZ ddlmZ ddlm	  m
Z
 e e¡Zdd„ Zdd	„ Zd
d„ Zdd„ Zdd„ ZdS )zUpdaters run at renewalé    N)Úerrors)Ú
interfaces)Ú	selectionc              
   C   s|   | j rt d¡ dS zt | |¡}W n6 tjk
rZ } zt d|¡ W Y ¢dS d}~X Y nX |rxt||| ƒ t	||| ƒ dS )a@  Run updaters that the plugin supports

    :param config: Configuration object
    :type config: interfaces.IConfig

    :param lineage: Certificate lineage object
    :type lineage: storage.RenewableCert

    :param plugins: List of plugins
    :type plugins: `list` of `str`

    :returns: `None`
    :rtype: None
    z"Skipping updaters in dry-run mode.Nz4Could not choose appropriate plugin for updaters: %s)
Údry_runÚloggerÚdebugÚplug_selZget_unprepared_installerr   ÚErrorZwarningÚ_run_updatersÚ_run_enhancement_updaters)ÚconfigÚlineageÚpluginsÚ	installerÚe© r   ú1/usr/lib/python3/dist-packages/certbot/updater.pyÚrun_generic_updaters   s    
r   c                 C   s@   | j rt d¡ dS | js0t|tjƒr0| |¡ t||| ƒ dS )a…  Helper function to run deployer interface method if supported by the used
    installer plugin.

    :param config: Configuration object
    :type config: interfaces.IConfig

    :param lineage: Certificate lineage object
    :type lineage: storage.RenewableCert

    :param installer: Installer object
    :type installer: interfaces.IInstaller

    :returns: `None`
    :rtype: None
    z*Skipping renewal deployer in dry-run mode.N)	r   r   r   Údisable_renew_updatesÚ
isinstancer   ZRenewDeployerZrenew_deployÚ_run_enhancement_deployers)r   r   r   r   r   r   Úrun_renewal_deployer'   s    

ÿ
r   c                 C   s    |j st|tjƒr| | ¡ dS )a;  Helper function to run the updater interface methods if supported by the
    used installer plugin.

    :param lineage: Certificate lineage object
    :type lineage: storage.RenewableCert

    :param installer: Installer object
    :type installer: interfaces.IInstaller

    :returns: `None`
    :rtype: None
    N)r   r   r   ZGenericUpdaterZgeneric_updates)r   r   r   r   r   r   r
   @   s    r
   c                 C   sB   |j r
dS tjD ],}t||d ƒr|d rt||d ƒ| ƒ qdS )a¸  Iterates through known enhancement interfaces. If the installer implements
    an enhancement interface and the enhance interface has an updater method, the
    updater method gets run.

    :param lineage: Certificate lineage object
    :type lineage: storage.RenewableCert

    :param installer: Installer object
    :type installer: interfaces.IInstaller

    :param config: Configuration object
    :type config: interfaces.IConfig
    NÚclassZupdater_function©r   ÚenhancementsZ_INDEXr   Úgetattr©r   r   r   Zenhr   r   r   r   Q   s
    
r   c                 C   sB   |j r
dS tjD ],}t||d ƒr|d rt||d ƒ| ƒ qdS )aº  Iterates through known enhancement interfaces. If the installer implements
    an enhancement interface and the enhance interface has an deployer method, the
    deployer method gets run.

    :param lineage: Certificate lineage object
    :type lineage: storage.RenewableCert

    :param installer: Installer object
    :type installer: interfaces.IInstaller

    :param config: Configuration object
    :type config: interfaces.IConfig
    Nr   Zdeployer_functionr   r   r   r   r   r   g   s
    
r   )Ú__doc__ZloggingZcertbotr   r   Zcertbot.pluginsr   r   Zcertbot.plugins.enhancementsr   r   Z	getLoggerÚ__name__r   r   r   r
   r   r   r   r   r   r   Ú<module>   s   
