HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/cloudinit/config/__pycache__/cc_snap.cpython-310.pyc
o

m[hH
�
@s�UdZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZe�e�Zd	d
ge
dgd�Zeed
<dZdd�Zdd�Zdede	dededdf
dd�ZdS)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�metacCs�|sdSt�d�t|t�r|��}n
t|t�s tdj|d���td|g}d�	|�}|D]}t�d|�
d�dd	��q,t�||�
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})�
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�asrt�r'�:/usr/lib/python3/dist-packages/cloudinit/config/cc_snap.py�add_assertionss"



��

r)cCs�|sdSt�d�t|t�rdd�t|���D�}n
t|t�s'tdj|d���t	d|�}g}|D]*}t|t
�}z	tj||d�Wq0tjyZ}z
|�
t
|��WYd}~q0d}~ww|rmd	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|]\}}|�qSr'r')�.0�_�vr'r'r(�
<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�strr�ProcessExecutionError�appendr�logexc�RuntimeError)r.�fixed_snap_commandsr0�commandr/�e�msgr'r'r(�run_commands;s8	


��

����r<�name�cfg�cloud�args�returncCsV|�di�}|st�d|�dSt|�dg�tj�|j��d��t	|�dg��dS)Nrz8Skipping module named %s, no 'snap' key in configurationrzsnapd.assertionsr.)
�getrrr)�os�pathr�paths�
get_ipath_curr<)r=r>r?r@�cfginr'r'r(�handlebs�
�rH)�__doc__�loggingrC�	cloudinitrr�cloudinit.cloudr�cloudinit.configr�cloudinit.config.schemar�cloudinit.settingsr�cloudinit.subpr�	getLogger�__name__rr�__annotations__rr)r<r3rrHr'r'r'r(�<module>s&
�"'