HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/boto/pyami/__pycache__/bootstrap.cpython-310.pyc
o

ckF[t�@s~ddlZddlZddlmZmZddlmZmZddlm	Z	ddl
Z
Gdd�de	�Zedkr=e�
dd	�e�Ze��dSdS)
�N)�get_instance_metadata�get_instance_userdata)�Config�BotoConfigPath)�
ScriptBasecsPeZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
�ZS)�	Bootstrapa\
    The Bootstrap class is instantiated and run as part of the PyAMI
    instance initialization process.  The methods in this class will
    be run from the rc.local script of the instance and will be run
    as the root user.

    The main purpose of this class is to make sure the boto distribution
    on the instance is the one required.
    cs d|_|��tt|���dS)Nz
/mnt/pyami)�working_dir�write_metadata�superr�__init__��self��	__class__��6/usr/lib/python3/dist-packages/boto/pyami/bootstrap.pyr(szBootstrap.__init__cCs�ttj�t�d�}|�d�t�}|D]
}|�d|||f�qt�}|�d|�|�d�|�d|j�|�	�t
�t_t�
�dS)N�wz[Instance]
z%s = %s
z
%s
z[Pyami]
zworking_dir = %s
)�open�os�path�
expanduserr�writerrr�closer�boto�config�init_logging)r
�fp�	inst_data�key�	user_datarrrr	-s

zBootstrap.write_metadatacCs4tj�d|j�tj�|j�st�|j�dSdS)NzWorking directory: %s)r�log�inforrr�exists�mkdirrrrr�create_working_dir>s�zBootstrap.create_working_dirc
CsHtj�ddd�}|�d�r5|�d�dkr |�d�\}}d|}nd}tj�dd	d
�}|�d||f�dS|�d�r�tj�dd	d
�}d}|dkrz|d8}z|jd|d�d}Wntyu}ztj�	d|�t
�d�WYd}~nd}~ww|dksH|�d�dkr�|�d�\}}nd}|jd||d�dS|�d�|�d|�dS)N�Boto�boto_updatezsvn:HEAD�svn�:rz-r%sz-rHEAD�
boto_locationz/usr/local/botozsvn update %s %s�gitz*/usr/share/python-support/python-boto/boto�
�zgit pull)�cwdzOgit pull attempt failed with the following exception. Trying again in a bit. %s��masterzgit checkout %sz.rm /usr/local/lib/python2.5/site-packages/botozeasy_install %s)rr�get�
startswith�find�split�run�	Exceptionr r!�time�sleep)r
�update�method�version�location�num_remaining_attempts�errr�	load_botoCs8


���
zBootstrap.load_botocCsjz$ddlm}||�}tj�|j|�d�d�}t|d��|�	��W|St
j�d|�d}Y|S)Nr)�
fetch_file�/���rzProblem Retrieving file: %s)
�
boto.utilsr?rr�joinrr3rr�readrr �	exception)r
�s3_filer?�frrrr�
fetch_s3_filebs�zBootstrap.fetch_s3_filecCsjtj�dd�}|r1|�d�}|D]"}|��}|�d�r |�|�}|r0|�d�s0|jd|dd�qdSdS)	N�Pyami�packages�,zs3:z.pyzeasy_install -Z %sF)�
exit_on_error)	rrr0r3�stripr1rH�endswithr4)r
�package_strrJ�packagerrr�
load_packagesms



��zBootstrap.load_packagescCs2|��|��|��|�dtj�d��dS)NzBootstrap Completed for %szinstance-id)r$r>rQ�notifyrr�get_instancerrrr�main{szBootstrap.main)�__name__�
__module__�__qualname__�__doc__rr	r$r>rHrQrT�
__classcell__rrrrrs
r�__main__�	bootstrapz/var/log/boto.log)rrrBrr�boto.pyami.configrr�boto.pyami.scriptbaserr6rrU�set_file_logger�bsrTrrrr�<module>sd�