Ë
    x[hl  ã            
       óÒ   — U d Z ddlZddlZddlmZmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ  ej                   e«      Zd	d
gedgdœZeed<   dZd„ Zd„ Zdede	dededdf
d„Zy)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                 óÖ  — | syt         j                  d«       t        | t        «      r| j	                  «       } n+t        | t
        «      st        dj                  | ¬«      «      ‚t        d|g}dj                  | «      }| D ]*  }t         j                  d|j                  d«      dd	 «       Œ, t        j                  ||j                  d
«      «       t        j                  |d¬«       y)a  Import 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ú
zSnap acking: %sr   é   zutf-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  — | syt         j                  d«       t        | t        «      r,t	        | j                  «       «      D ��cg c]  \  }}|‘Œ	 } }}n+t        | t        «      st        dj                  | ¬«      «      ‚t        d| «      }g }|D ]*  }t        |t        «      }	 t        j                  ||¬«       Œ, |r7dj                  |¬«      }t        j                  t         |«       t!        |«      ‚yc c}}w # t        j                  $ r$}|j                  t        |«      «       Y d}~ŒŸd}~ww xY w)	aH  Run 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)r   r   r   r   ÚsortedÚitemsr   r   r   r	   Ú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                 ó^  — |j                  di «      }|st        j                  d| «       y t        j                  |«       t        |j                  dg «      t        j                  j                  |j                  j                  «       d«      «       t        |j                  dg «      «       y )Nr   z8Skipping module named %s, no 'snap' key in configurationr   zsnapd.assertionsr-   )Úgetr   r   r   Úwait_for_snap_seededr*   ÚosÚpathr!   ÚpathsÚget_ipath_curr=   )r>   r?   r@   rA   Úcfgins        r)   ÚhandlerK   b   s„   € Ø�G‰G�F˜BÓ€EÙÜ�	‰	ØFÈô	
ð 	Ü×Ñ˜eÔ$ÜØ�	‰	�, Ó#Ü
�‰�‰�U—[‘[×.Ñ.Ó0Ð2DÓEôô �—‘˜: rÓ*Õ+r+   )Ú__doc__ÚloggingrF   Ú	cloudinitr   r   Úcloudinit.cloudr   Úcloudinit.configr   Úcloudinit.config.schemar   Úcloudinit.settingsr   Úcloudinit.subpr	   Ú	getLoggerÚ__name__r   r   Ú__annotations__r    r*   r=   r2   r   rK   © r+   r)   ú<module>rX      s�   ðò
 Cã Û 	ç  Ý !Ý #Ý .Ý +Ý /à€g×Ñ˜Ó!€ð ØˆzØØ &˜xñ	€€jó ð €ò&ò<$ ðN,�ð ,˜6ð ,¨%ð ,°tð ,Àô ,r+   