%PDF- %PDF-
Direktori : /snap/core/17212/usr/lib/python3/dist-packages/cloudinit/cmd/__pycache__/ |
Current File : //snap/core/17212/usr/lib/python3/dist-packages/cloudinit/cmd/__pycache__/clean.cpython-35.pyc |
"�T` � @ s� d Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m Z m Z d d l m Z m Z m Z m Z d d � Z d d d � Z d d d � Z d d � Z d d � Z e d k r� e � d S)zEDefine 'clean' utility and handler as part of cloud-init commandline.� N)�Init)�ProcessExecutionError�subp)�del_dir�del_file�get_config_logfiles�is_linkc C s t j j d | d � d S)NzERROR: � )�sys�stderr�write)�msg� r �5/usr/lib/python3/dist-packages/cloudinit/cmd/clean.py�error s r c C s� | s t j d d d d � } | j d d d d d d d d d d �| j d d d d d d d d �| j d d d d d d d d d 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)�parserr r r � get_parser s r Fc C s: t d g � } | j � | rC x! t | j � D] } t | � q/ Wt j j | j j � s_ d St j j | j j d � } x� t j d | j j � D]� } | | k r� | r� q� y: t j j | � r� t | � r� t | � n t | � Wq� t k r1} z% t d j | t | � � � d SWYd d } ~ Xq� Xq� Wd S)a4 Helper 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_depsr Zseedz%s/*zCould not remove {0}: {1}� N)r Zread_cfgr Zcfgr �os�path�isdir�pathsZ cloud_dir�join�globr r �OSErrorr �format�str)r r ZinitZlog_fileZ seed_pathr! �er r r �remove_artifacts/ s&