o
    Ü!dš  ã                   @   sH   d dl Z d dlZd dlZd dlmZmZ d dlmZ G dd„ deƒZdS )é    N)Úvalidate_instanceÚvalidate_region)ÚBasicCommandc                   @   s,   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	S )
Ú	UninstallÚ	uninstallzBUninstalls the AWS CodeDeploy Agent from the on-premises instance.c              
   C   s†   |}| j |_t||ƒ t|ƒ |j ¡  z|  |¡ |  |¡ W d S  tyB } zt	j
 ¡  t	j d |¡¡ W Y d }~d S d }~ww )NzÏERROR
{0}
Uninstall the AWS CodeDeploy Agent on the on-premises instance by following the instructions in "Configure Existing On-Premises Instances by Using AWS CodeDeploy" in the AWS CodeDeploy User Guide.
)Z_sessionZsessionr   r   ÚsystemZvalidate_administratorÚ_uninstall_agentÚ_delete_config_fileÚ	ExceptionÚsysÚstdoutÚflushÚstderrÚwriteÚformat)ÚselfZparsed_argsZparsed_globalsÚparamsÚe© r   úNusr/lib/python3.10/site-packages/awscli/customizations/codedeploy/uninstall.pyÚ	_run_main   s    



ú€þzUninstall._run_mainc                 C   s(   t j d¡ |j |¡ t j d¡ d S )Nz)Uninstalling the AWS CodeDeploy Agent... úDONE
)r   r   r   r   r   )r   r   r   r   r   r   3   s   zUninstall._uninstall_agentc              
   C   sd   t j d¡ z	t |jj¡ W n ty) } z|jtj	kr|‚W Y d }~nd }~ww t j d¡ d S )Nz3Deleting the on-premises instance configuration... r   )
r   r   r   ÚosÚremover   ZCONFIG_PATHÚOSErrorÚerrnoÚENOENT)r   r   r   r   r   r   r	   8   s   ÿ€ÿzUninstall._delete_config_fileN)Ú__name__Ú
__module__Ú__qualname__ÚNAMEZDESCRIPTIONr   r   r	   r   r   r   r   r      s    ÿr   )	r   r   r   Z&awscli.customizations.codedeploy.utilsr   r   Zawscli.customizations.commandsr   r   r   r   r   r   Ú<module>   s   