%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core/17212/usr/lib/python3/dist-packages/cloudinit/cmd/__pycache__/
Upload File :
Create Path :
Current File : //snap/core/17212/usr/lib/python3/dist-packages/cloudinit/cmd/__pycache__/clean.cpython-35.pyc



"�T`
�@s�dZddlZddlZddlZddlZddlmZddlmZm	Z	ddl
mZmZm
Z
mZdd�Zddd	�Zd
dd�Zd
d�Zdd�Zedkr�e�dS)zEDefine 'clean' utility and handler as part of cloud-init commandline.�N)�Init)�ProcessExecutionError�subp)�del_dir�del_file�get_config_logfiles�is_linkcCstjjd|d�dS)NzERROR: �
)�sys�stderr�write)�msg�r�5/usr/lib/python3/dist-packages/cloudinit/cmd/clean.py�errorsrcCs�|stjdddd�}|jddddd	d
ddd
d�|jddddd	d
d
d�|jddddd	d
ddd
d�|S)a#Build or extend an arg parser for clean utility.

    @param parser: Optional existing ArgumentParser instance representing the
        clean subcommand which will be extended to support the args of
        this utility.

    @returns: ArgumentParser with proper argument configuration.
    �prog�cleanZdescriptionzARemove logs and artifacts so cloud-init re-runs on a clean systemz-lz--logs�action�
store_true�defaultF�dest�remove_logs�helpzRemove cloud-init logs.z-rz--rebootz;Reboot system after logs are cleaned so cloud-init re-runs.z-sz--seed�remove_seedz5Remove cloud-init seed directory /var/lib/cloud/seed.)�argparse�ArgumentParser�add_argument)�parserrrr�
get_parsers			rFcCs:tdg�}|j�|rCx!t|j�D]}t|�q/Wtjj|jj	�s_dStjj
|jj	d�}x�tjd|jj	�D]�}||kr�|r�q�y:tjj|�r�t|�r�t
|�n
t|�Wq�tk
r1}z%tdj|t|���dSWYdd}~Xq�Xq�WdS)a4Helper which removes artifacts dir and optionally log files.

    @param: remove_logs: Boolean. Set True to delete the cloud_dir path. False
        preserves them.
    @param: remove_seed: Boolean. Set True to also delete seed subdir in
        paths.cloud_dir.
    @returns: 0 on success, 1 otherwise.
    Zds_depsrZseedz%s/*zCould not remove {0}: {1}�N)rZread_cfgrZcfgr�os�path�isdir�pathsZ	cloud_dir�join�globrr�OSErrorr�format�str)rrZinitZlog_fileZ	seed_pathr!�errr�remove_artifacts/s&	
 
r*cCs�t|j|j�}|dkr�|jr�dddg}yt|dd�WnGtk
r�}z'tdj|t|���d}WYd	d	}~XnX|S)
z3Handle calls to 'cloud-init clean' as a subcommand.rZshutdownz-rZnowZcaptureFz-Could not reboot this system using "{0}": {1}rN)	r*rrZrebootrrrr'r()�name�argsZ	exit_code�cmdr)rrr�handle_clean_argsOsr.cCs)t�}tjtd|j���dS)z4Tool to collect and tar all cloud-init related logs.rN)rr
�exitr.�
parse_args)rrrr�main^s	r1�__main__)�__doc__rr%r r
Zcloudinit.stagesrZcloudinit.subprrZcloudinit.utilrrrrrrr*r.r1�__name__rrrr�<module>s" 

Zerion Mini Shell 1.0