HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-10-0-8-47 6.8.0-1021-aws #23~22.04.1-Ubuntu SMP Tue Dec 10 16:31:58 UTC 2024 aarch64
User: ubuntu (1000)
PHP: 8.1.2-1ubuntu2.22
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/cloudinit/handlers/__pycache__/__init__.cpython-310.pyc
o

�Ad�&�
@s ddlZddlZddlmZddlmZddlmZmZddlm	Z	m
Z
mZe�e
�ZdZdZdZd	ZeegZd
gZdZdZd
dddd
dddddddd�Zeee���dd�d�ZGdd�dejd�Zdd �Zd!d"�Zd#d$�Z d%d&�Z!d'd(�Z"d)d*�Z#d+d,�Z$d-d.�Z%efd/d0�Z&d3d1d2�Z'dS)4�N)�importer)�log)�
type_utils�util)�FREQUENCIES�
PER_ALWAYS�PER_INSTANCEztext/x-not-multipartzapplication/octet-stream�__end__�	__begin__ztext/part-handlerzpart-handler-%03dz	part-%03dztext/x-include-urlztext/x-include-once-urlztext/x-shellscriptztext/cloud-configztext/cloud-boothookztext/cloud-config-archiveztext/cloud-config-jsonpztext/jinja2�text/x-shellscript-per-boot�text/x-shellscript-per-instance�text/x-shellscript-per-once)z#includez
#include-oncez#!z
#cloud-configz
#part-handlerz#cloud-boothookz#cloud-config-archivez#cloud-config-jsonpz## template: jinjarrr
cCsdt|�S)Nr)�len)�e�r�=/usr/lib/python3/dist-packages/cloudinit/handlers/__init__.py�<lambda>?sr)�keyc@s4eZdZddd�Zdd�Zdd�Zejdd	��Zd
S)�Handler�cCs||_||_dS�N)�handler_version�	frequency)�selfr�versionrrr�__init__Ds
zHandler.__init__cCsdt�|�|��fS)Nz%s: [%s])r�obj_name�
list_types�rrrr�__repr__HszHandler.__repr__cCs&t|d�s	td��dd�t|d�D�S)N�prefixesz#Missing prefixes subclass attributecSsg|]}t|�qSr)�INCLUSION_TYPES_MAP)�.0�prefixrrr�
<listcomp>Ps��z&Handler.list_types.<locals>.<listcomp>)�hasattr�NotImplementedError�getattrrrrrrKs

�zHandler.list_typescOst��r)r&)r�args�kwargsrrr�handle_partUszHandler.handle_partN)r)	�__name__�
__module__�__qualname__rrr�abc�abstractmethodr*rrrrrCs

r)�	metaclassc	Cs|j}|tks|tkr|tksdSz	|j}t|�}Wntttfy(d}Ynw|d}z@t�	d|||||�|dkrI|�
||||||�WdS|dkrY|�
|||||�WdS|dkrh|�
||||�WdStd|��ty�t�
td|||||�YdSw)N��Content-Typez1Calling handler %s (%s, %s, %s) with frequency %s�rzUnknown module version %sz8Failed calling handler %s (%s, %s, %s) with frequency %s)rrrr�int�	TypeError�
ValueError�AttributeError�LOG�debugr*�	Exceptionr�logexc)	�mod�data�filename�payloadr�headers�mod_freq�mod_ver�content_typerrr�run_partZsX�����
�
��rDcC�dti}t||dd||�dS�Nr2)�
CONTENT_STARTrD�r<r=rr@rrr�
call_begin���rIcCrErF)�CONTENT_ENDrDrHrrr�call_end�rJrLc
	Cs�|d}t|}|d}tj�|dd|�}|�d�s d|}t�||d�|d}ztt�	|��}	t
|	|d	|�|j|	d
d�|d|d<WdSty\t�
td
||�YdSw)N�handlercountr�
handlerdirz%sz.pyz%s.pyi��handlersr=T)�initializedr1z7Failed at registering python file: %s (part handler %s))�PART_HANDLER_FN_TMPL�os�path�join�endswithr�
write_file�
fixup_handlerr�
import_modulerI�registerr:r;r8)
�pdata�_ctype�	_filenamer?�curcount�modnamer�modfnamerOr<rrr�walker_handle_handler�s*

��r`cCs�z2t|t�r|�dd�d}n|dd|�jdd��dd�d}t|�|kr0|d|�}W|SW|StyB|d|�}Y|Sw)N�
r1r��ignore)�errors)�
isinstance�str�split�decoder�UnicodeDecodeError)�blob�size�startrrr�_extract_first_or_bytes�s
$���rmcCsZz|�d�WSttfy#z|�d�WYSty"YY|Swty,Y|Sw)N�
string_escape�unicode_escape)�encode�LookupErrorr5r7)�textrrr�_escape_string�s��rscCs�|d}||�d�vrt�d|�dS|tvr t||||�dS|d}||vr9t|||d|||d|�dS|r\t|d�}dt|�}|tkrSt�	d	||�dSt�	d
||�dSt�d|�dS)Nr2�excludedzcontent_type "%s" is excludedrOr=r�z'%s...'z)Unhandled non-multipart (%s) userdata: %sz0Unhandled unknown content-type (%s) userdata: %szEmpty payload of type %s)
�getr8r9�PART_CONTENT_TYPESr`rDrmrs�NOT_MULTIPART_TYPE�warning)r=r>r?r@rCrOrl�detailsrrr�walker_callback�s@�
��r{c	Cs�d}|��D]:}|��dkrq|��}|durt}|��}|s#t|}t|�}t�|�||d<t	�
|�}|||||�|d}qdS)Nr�	multipartr2r1)�walk�get_content_maintype�get_content_type�
OCTET_TYPE�get_filename�PART_FN_TPL�dictr8r9r�fully_decoded_payload)	�msg�callbackr=�partnum�part�ctyper>r@r?rrrr}s"


�r}cCsTt|d�st|dd�t|d�st|d|�|S|j}|r(|tvr(t�d||�|S)Nrr1rz&Handler %s has an unknown frequency %s)r%�setattrrrr8ry)r<�def_freq�freqrrrrWs

�rWcCsVz	t�|���}Wnty|YSw|��}tD]
}|�|�r(t|Sq|Sr)r�
decode_binary�lowerri�lstrip�INCLUSION_SRCH�
startswithr!)r?�default�
payload_lcrrrrr�type_from_starts_with$s�
�r�r)(r.rR�	cloudinitrr�loggingrr�cloudinit.settingsrrr�	getLoggerr+r8rxr�rKrG�CONTENT_SIGNALSrwrQr�r!�sorted�list�keysr��ABCMetarrDrIrLr`rmrsr{r}rWr�rrrr�<module>sT

��0)