File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/extmods.cpython-310.pyc
Back
o ;j� � @ s~ d Z ddlZddlZddlZddlZddlZddlZddlZddl Zddl mZ e�e �Zdd� Zdd� Z d dd �ZdS )z) Functions used to sync external modules � N)�DEFAULT_HASH_TYPEc C s4 g }t jj�| �D ]\}}}|s|s|�|� q |S )N)�salt�utils�path�os_walk�append)�rootdir� emptydirs�root�dirs�files� r �F/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/extmods.py�_list_emptydirs s �r c C sT g }t jj�| �D ]\}}}|D ]}tj�|| ��d�}|�tj�||�� qq |S )N�.) r r r r �os�relpath�stripr �join)r Z file_listr r r �filenamer r r r �_listdir_recursively s �r c C s |du rdg}|du r| d }nt |t�r||�d�i}nt |t�s(t�d|� |du r1| d }nt |t�r>||�d�i}nt |t�sIt�d|� t |t�rS|�d�}g }t� }tjj � d| �}tj� | d |� �}d } tjj�d���� �zXtj�|�s�t�d|� zt�|� W n ty� t�d |� Y nw tj�| ���} |D ]�}t�d||� g }t�d||� |�| j||d ddd�� tj� | d d|d|� ��} t�d| � |D ]�}tj�|| �}tj�|�d �tjd�}|r�||v r�||| vr�q�|�r||v �r||| v �rq�|�|� tj� ||�}t�d||� tj�|��rR| �dt �}tjj!�"||�}tjj!�"||�}||k�rQt#�$||� |�%|� d|� �� q�tj�&|�}tj�|��sdt�|� t#�$||� |�%|� d|� �� q�q�W d � n 1 �s�w Y t'|�} | d du �r�tt(|��}|| D ]}tj� ||�}tj�|��r�d} t�)|� �q� t*|�}|�s�n|D ]}d} t#j+|dd� �q��q�W n t,�y� } z t�d||� W Y d}~nd}~ww W d � || fS W d � || fS 1 �sw Y || fS )zB Sync custom modules into the extension_modules directory N�base�extmod_whitelist�,z3extmod_whitelist must be a string or dictionary: %s�extmod_blacklistz3extmod_blacklist must be a string or dictionary: %s�_Zextension_modulesF�? zCreating module dir '%s'z;Cannot create cache module directory %s. Check permissions.zSyncing %s for environment '%s'zLoading cache from %s, for %szE@\.(pyx?|so|zip)$)Z include_emptyZinclude_patZexclude_patZcachedirr zLocal cache dir: '%s'r r zCopying '%s' to '%s'� hash_typeZclean_dynamic_modulesT)� ignore_errorszFailed to sync %s module: %s)-� isinstance�str�split�dict�log�error�setr r �url�creater r r r Z set_umask�isdir�info�makedirs�OSError� fileclientZget_file_client�extendZ cache_dir�debugr �splitext�replace�sep�add�isfile�getr Z hashutilsZget_hash�shutil�copyfiler �dirname�boolr �remover �rmtree� Exception)�optsZformZsaltenvr r �retZremote�sourceZmod_dirZtouchedr, Zsub_env�cacheZlocal_cache_dirZfn_r Zrelname�destr Z src_digestZ dst_digestZdest_dir�current�fullr Zemptydir�excr r r �sync$ s� � � ���� ��� � ���5 ������ �R� �R�RrD )NNN)�__doc__�loggingr r5 Zsalt.fileclientr Zsalt.utils.filesZsalt.utils.hashutilsZsalt.utils.pathZsalt.utils.urlZsalt.configr � getLogger�__name__r# r r rD r r r r �<module> s"