
¡\\r  ã               @   s£   d  Z  d d l Z d d l m Z d d l m Z d d l m Z d d l j	 j
 Z
 e j 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 j d ƒ d Sy t j |  | ƒ } Wn< t j k
 rn } z t j d | ƒ d SWYd d } ~ Xn X| r• t | | |  ƒ 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   sW   |  j  r t j d ƒ d S|  j rC t | t j ƒ rC | j | ƒ 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( | j |  ƒ 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   sY   | j  r d SxE t j D]: } t | | d ƒ r | d r t | | d ƒ |  ƒ q Wd 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   ÚenhancementsÚ_INDEXr   Úgetattr)r   r   r   Úenhr   r   r   r   Q   s
    	r   c             C   sY   | j  r d SxE t j D]: } t | | d ƒ r | d r t | | d ƒ |  ƒ q Wd 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_function)r   r   r   r   r   )r   r   r   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   