a '¡DgÓã@sPddlZddlZddlmZmZmZddlmZe e ¡Z Gdd„dej ƒZ dS)éN)ÚhandlersÚsubpÚutil)Ú PER_ALWAYSc@s*eZdZdgZdd„Zdd„Zdd„ZdS) ÚBootHookPartHandlerz#cloud-boothookcKs2tj |t¡| d¡|_d|_|r.| ¡|_dS)NZ boothooks)rÚHandlerÚ__init__rZ get_ipathÚ boothook_dirÚ instance_idZget_instance_id)ÚselfÚpathsZ datasourceÚ_kwargs©rú@/usr/lib/python3.9/site-packages/cloudinit/handlers/boot_hook.pyrs  zBootHookPartHandler.__init__cCsJt |¡}tj |j|¡}tjt |¡|jdd}t  ||  ¡d¡|S)Nr)ÚprefixiÀ) rZclean_filenameÚosÚpathÚjoinr Zstrip_prefix_suffixZdos2unixÚprefixesZ write_fileÚlstrip)r ÚpayloadÚfilenameÚfilepathÚcontentsrrrÚ _write_part s ÿzBootHookPartHandler._write_partcCs˜|tjvrdS| ||¡}z8|jr0dt|jƒini}t d¡tj|g|ddWn@tjytt   td|¡Yn t y’t   td|¡Yn0dS)NZ INSTANCE_IDzExecuting boothookF)Z update_envZcapturez#Boothooks script %s execution errorz'Boothooks unknown error when running %s) rZCONTENT_SIGNALSrr ÚstrÚLOGÚdebugrZProcessExecutionErrorrZlogexcÚ Exception)r ÚdataZctyperrZ frequencyrÚenvrrrÚ handle_part)s   ÿý  ÿzBootHookPartHandler.handle_partN)Ú__name__Ú __module__Ú __qualname__rrrr!rrrrrs r) ZloggingrZ cloudinitrrrZcloudinit.settingsrZ getLoggerr"rrrrrrrÚ s