Current File : //usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_snap.cpython-312.pyc
�

Ӈgl
�
���UdZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZej e�Zd	d
ge
dgd�Zeed
<dZd�Zd�Zdede	dededdf
d�Zy)z<Snap: Install, configure and manage snapd and snap packages.�N)�subp�util)�Cloud)�Config)�
MetaSchema)�PER_INSTANCE)�prepend_base_command�cc_snap�ubuntu�snap)�id�distros�	frequency�activate_by_schema_keys�metac���|sytjd�t|t�r|j	�}n+t|t
�st
dj|����td|g}dj|�}|D]*}tjd|jd�dd	��,tj||jd
��tj|d��y)
aImport list of assertions.

    Import assertions by concatenating each assertion into a
    string separated by a '\n'.  Write this string to a instance file and
    then invoke `snap ack /path/to/file` and check for errors.
    If snap exits 0, then all assertions are imported.
    Nz'Importing user-provided snap assertionsz8assertion parameter was not a list or dict: {assertions})�
assertions�ack�
zSnap acking: %sr�zutf-8T)�capture)�LOG�debug�
isinstance�dict�values�list�	TypeError�format�SNAP_CMD�join�splitr�
write_file�encoder)r�assertions_file�snap_cmd�combined�asrts     �:/usr/lib/python3/dist-packages/cloudinit/config/cc_snap.py�add_assertionsr*s������I�I�7�8��*�d�#��&�&�(�
�
�
�D�
)��F�M�M�%�
N�
�
�	
��%��1�H��y�y��$�H��<���	�	�#�T�Z�Z��%5�a��%:�;�<�	�O�O�O�X�_�_�W�%=�>��I�I�h��%�c�n�|sytjd�t|t�r,t	|j��D��cgc]\}}|��	}}}n+t|t�stdj|����td|�}g}|D]*}t|t�}	tj||���,|r7dj|��}tjt|�t!|��ycc}}w#tj$r$}|jt|��Yd}~��d}~wwxYw)	aHRun the provided commands provided in snap:commands configuration.

    Commands are run individually. Any errors are collected and reported
    after attempting all commands.

    @param commands: A list or dict containing commands to run. Keys of a
        dict will be used to order the commands provided as dict values.
    Nz#Running user-provided snap commandsz5commands parameter was not a list or dict: {commands})�commandsr)�shellz.Failures running snap commands:
{cmd_failures})�cmd_failures)rrrr�sorted�itemsrrrr	�strr�ProcessExecutionError�appendr�logexc�RuntimeError)	r-�_�v�fixed_snap_commandsr/�commandr.�e�msgs	         r)�run_commandsr=;s$�����I�I�3�4��(�D�!�"(����)9�":�;�$�!�Q�A�;��;�
��$�
'��C�J�J�!�
K�
�
�	
�/�v�x�@���L�&�(���7�C�(��	(��I�I�g�U�+�(��?�F�F�%�G�
��	
���C����3�����#<���)�)�	(�����A��'�'��	(�s�C7�$C=�=D4�D/�/D4�name�cfg�cloud�args�returnc�^�|jdi�}|stjd|�ytj|�t|jdg�tjj|jj�d��t|jdg��y)Nrz8Skipping module named %s, no 'snap' key in configurationrzsnapd.assertionsr-)�getrrr�wait_for_snap_seededr*�os�pathr!�paths�
get_ipath_curr=)r>r?r@rA�cfgins     r)�handlerKbs����G�G�F�B��E���	�	�F��	
�	����e�$��
�	�	�,��#�
�����U�[�[�.�.�0�2D�E������:�r�*�+r+)�__doc__�loggingrF�	cloudinitrr�cloudinit.cloudr�cloudinit.configr�cloudinit.config.schemar�cloudinit.settingsr�cloudinit.subpr	�	getLogger�__name__rr�__annotations__r r*r=r2rrK�r+r)�<module>rXs���
C��	� �!�#�.�+�/��g����!����z�� &�x�	��j����&�<$ �N,��,�6�,�%�,�t�,��,r+