HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_snap.cpython-38.pyc
U

��0hH
�@s�UdZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZe�e�Zd	d
ge
dgd�Zeed
<dZdd�Zdd�Zee	eedd�dd�ZdS)z<Snap: Install, configure and manage snapd and snap packages.�N)�subp�util)�Cloud)�Config)�
MetaSchema)�PER_INSTANCE)�prepend_base_commandZcc_snapZubuntu�snap)�idZdistrosZ	frequencyZactivate_by_schema_keys�metacCs�|sdSt�d�t|t�r&|��}nt|t�s@tdj|d���td|g}d�	|�}|D]}t�d|�
d�dd	��qXt�||�
d
��tj|dd�dS)
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})�
assertionsZack�
zSnap acking: %sr�zutf-8T)Zcapture)�LOG�debug�
isinstance�dict�values�list�	TypeError�format�SNAP_CMD�join�splitrZ
write_file�encoder)rZassertions_fileZsnap_cmdZcombinedZasrt�r�:/usr/lib/python3/dist-packages/cloudinit/config/cc_snap.py�add_assertionss"



��

rcCs�|sdSt�d�t|t�r4dd�t|���D�}nt|t�sNtdj|d���t	d|�}g}|D]T}t|t
�}ztj||d�Wq`tjk
r�}z|�
t
|��W5d}~XYq`Xq`|r�d	j|d
�}t�t|�t|��dS)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 commandscSsg|]\}}|�qSrr)�.0�_�vrrr�
<listcomp>Isz run_commands.<locals>.<listcomp>z5commands parameter was not a list or dict: {commands})�commandsr	)�shellz.Failures running snap commands:
{cmd_failures})�cmd_failures)rrrr�sorted�itemsrrrr�strrZProcessExecutionError�appendrZlogexc�RuntimeError)r"Zfixed_snap_commandsr$Zcommandr#�e�msgrrr�run_commands;s2	


��

"�r,)�name�cfg�cloud�args�returncCsV|�di�}|s t�d|�dSt|�dg�tj�|j��d��t	|�dg��dS)Nr	z8Skipping module named %s, no 'snap' key in configurationrzsnapd.assertionsr")
�getrrr�os�pathr�pathsZ
get_ipath_curr,)r-r.r/r0Zcfginrrr�handlebs�
�r6)�__doc__Zloggingr3Z	cloudinitrrZcloudinit.cloudrZcloudinit.configrZcloudinit.config.schemarZcloudinit.settingsrZcloudinit.subprZ	getLogger�__name__rr�__annotations__rrr,r'rr6rrrr�<module>s$
�'