| Server IP : 3.96.16.70 / Your IP : 216.73.216.15 Web Server : Apache System : Linux ip-172-31-26-103.ca-central-1.compute.internal 6.1.163-186.299.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Feb 24 16:35:42 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /lib/python3.9/site-packages/cfnbootstrap/__pycache__/ |
Upload File : |
a
��0i�0 � @ s� d dl mZmZ d dlmZ d dlmZ d dlZd dlZd dl Z d dl
Z
d dlmZ d dl
Z
d dlZd dlZd dlZe�d�ZG dd� de�ZdS ) � )�security�util)� ToolError)�contextmanagerN)�requestszcfn.initc @ s� e Zd ZdZdZedd� �Zedd� �Zedd� �Zd d
� Z e
dd� �Zd
d� Zdd� Z
dd� Zdd� Ze�� dd� �Zdd� ZdS )�FileToolz
Writes files to disk
� c C sF t tjd�rtj�||�S tj�tj�|��tj�tj�|��kS d S )N�samefile)�hasattr�os�pathr �normcase�abspath)�cls�f1�f2� r �:/usr/lib/python3.9/site-packages/cfnbootstrap/file_tool.py�is_same_file( s zFileTool.is_same_filec C s� t j�|�t j�|�krdS | �||�r,dS t|d���}t|d��n}d}|�|�}|�|�}||kr�W d � W d � dS |sHW d � W d � dS qHW d � n1 s�0 Y W d � n1 s�0 Y dS )zA
Return true if f1 and f2 have the same content.
FT�rbr N)r r �getsizer �open�read)r r r �fp1�fp2�bufsize�b1�b2r r r �compare_file_contents0 s
zFileTool.compare_file_contentsc C s4 t j�|�rdS tj�d�r0t�|�p.|�d�S dS )a2
Compatibility version of os.path.isabs:
- On Unix: use os.path.isabs() as usual.
- On Windows: also treat '/tmp/...', '/var/...', and similar Unix-style
root paths as absolute (for backward compatibility with older
cfn-bootstrap / Python versions).
T�win�/F)r r �isabs�sys�platform�
startswith�ntpath)r r r r r �
is_abs_compatF s
zFileTool.is_abs_compatc
C s� g }|� � st�d� |S t|�� dd� d�D �]�\}}| �|�sNtd| ��d|v oht�t |d d��}|r�d|vr�td ��n2t
j�|�r�t
�t
j�|�|d �r�t�d
|� q.t
j�|�}t
j�|�s�t
j�|�s�t�d|� t
�|� ntd| ��d
}t
j�|��r"d}t�t
�|�j�} | �||���� |�r\t�d||d � t
�|d |� n�d|v �op| �|� }
t�d|� |
�r�t|ddd��}| �|||� W d � n1 �s�0 Y n:t|d��}| �|||� W d � n1 �s�0 Y d|v �r8t�d||d � t
�|t�t |d d��� n^|�r^t�d|t| �� t
�|| � n8t�t
�|�j�} | d@ } t�d|t| �� t
�|| � t�||� d�|� d�� W d � q.1 �s�0 Y q.|S )at
Write a set of files to disk, returning a list of the files that have changed.
Arguments:
action -- a dict of pathname to attributes, such as owner, group, mode, content, and encoding
auth_config -- an AuthenticationConfig object for managing authenticated downloads
Exceptions:
ToolError -- on expected failures
zNo files specifiedc S s | d S )Nr r )Zpairr r r �<lambda>n � z FileTool.apply.<locals>.<lambda>)�keyz)File specified with non-absolute path: %s�mode� �contentz-Symbolic link specified without a destinationzSymbolic link %s already existsz,Parent directory %s does not exist, creatingz(Parent directory %s exists and is a fileFTz(%s is specified as a symbolic link to %szWriting content to %s�w�utf-8)�encodingN�wbzSetting mode for %s to %szGNo mode specified for %s. Setting permissions of the existing file: %s.i� zDNo mode specified for %s. The file will be created with the mode: %s�owner�group)!�keys�log�debug�sorted�itemsr&