o
    ÙKÕi°	  ã                   @   s
  d dl Z d dlmZmZmZmZmZmZ d dlm	Z	 d dl
mZmZmZ d dlmZ d dlmZmZ e  e e¡¡Zdejfdd	„Ze	 ¡ dejfd
d„ƒZdejfdd„Ze	je	 d¡dejfdd„ƒƒZedejej edej!eedej"dg d¢dd�gd�gd�Z#dS )é    N)Úapt_newsÚconfigÚcontractÚ
exceptionsÚmessagesÚutil)Úcli_util)ÚProArgumentÚProArgumentGroupÚ
ProCommand)ÚHelpCategory)Úrefresh_motdÚupdate_motd_messagesÚcfgc              
   C   sF   z|  ¡  W n ty } z	t |¡ t ¡ ‚d }~ww ttjƒ d S ©N)	Úprocess_configÚRuntimeErrorÚLOGÚ	exceptionr   ÚRefreshConfigFailureÚprintr   ÚREFRESH_CONFIG_SUCCESS)Úargsr   Úexc© r   ú6/usr/lib/python3/dist-packages/uaclient/cli/refresh.pyÚ_action_refresh_config   s   
€þr   c                 C   s6   zt  |¡ W n tjy   t ¡ ‚w ttjƒ d S r   )r   Úrefreshr   ÚConnectivityErrorÚRefreshContractFailurer   r   ÚREFRESH_CONTRACT_SUCCESS)Ú_argsr   r   r   r   Ú_action_refresh_contract   s   ÿr"   c              
   C   s\   zt |ƒ tƒ  |jrt |¡ W n ty& } z	t |¡ t ¡ ‚d }~ww t	t
jƒ d S r   )r   r   r   Úupdate_apt_newsÚ	Exceptionr   r   r   ÚRefreshMessagesFailurer   r   ÚREFRESH_MESSAGES_SUCCESS)r!   r   r   r   r   r   Ú_action_refresh_messages   s   
€
€þr'   zpro refreshc                K   s^   | j d u s
| j dkrt| |ƒ | j d u s| j dkrt| |ƒ | j d u s(| j dkr-t| |ƒ dS )Nr   r   r   r   )Útargetr   r"   r'   )r   r   Úkwargsr   r   r   Úaction_refresh.   s   


r*   r   Tr(   ú?)r   r   r   )ÚhelpÚnargsÚchoicesÚdefault)Ú	arguments)r,   ÚdescriptionÚactionÚpreserve_descriptionÚhelp_categoryÚargument_groups)$ÚloggingÚuaclientr   r   r   r   r   r   Úuaclient.clir   Úuaclient.cli.commandsr	   r
   r   Úuaclient.cli.parserr   Úuaclient.timer.update_messagingr   r   Ú	getLoggerÚreplace_top_level_logger_nameÚ__name__r   ÚUAConfigr   Úassert_attachedr"   r'   Úassert_rootÚassert_lock_filer*   ÚCLI_ROOT_REFRESHÚCLI_REFRESH_DESCÚOTHERÚCLI_REFRESH_TARGETÚrefresh_commandr   r   r   r   Ú<module>   sB     	ûÿÿÿ
ù