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: //proc/self/root/lib/python3/dist-packages/cloudinit/handlers/__pycache__/__init__.cpython-38.pyc
U

Ӈg}&�
@sddlZddlZddlZddlmZmZmZddlmZm	Z	m
Z
e�e�Z
dZdZdZdZeegZdgZd	Zd
Zddd
dddddddddd�Zeee���dd�d�ZGdd�dejd�Zdd�Zdd �Zd!d"�Zd#d$�Z d%d&�Z!d'd(�Z"d)d*�Z#d+d,�Z$e
fd-d.�Z%d1d/d0�Z&dS)2�N)�importer�
type_utils�util)�FREQUENCIES�
PER_ALWAYS�PER_INSTANCEztext/x-not-multipartzapplication/octet-streamZ__end__Z	__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>>�r)�keyc@s4eZdZddd�Zdd�Zdd�Zejdd	��Zd
S)�Handler�cCs||_||_dS�N)�handler_version�	frequency)�selfr�versionr
r
r�__init__CszHandler.__init__cCsdt�|�|��fS)Nz%s: [%s])rZobj_name�
list_types�rr
r
r�__repr__GszHandler.__repr__cCs,t|d�std��ndd�t|d�D�SdS)N�prefixesz#Missing prefixes subclass attributecSsg|]}t|�qSr
)�INCLUSION_TYPES_MAP)�.0�prefixr
r
r�
<listcomp>Os�z&Handler.list_types.<locals>.<listcomp>)�hasattr�NotImplementedError�getattrrr
r
rrJs


�zHandler.list_typescOs
t��dSr)r#)r�args�kwargsr
r
r�handle_partTszHandler.handle_partN)r)	�__name__�
__module__�__qualname__rrr�abc�abstractmethodr'r
r
r
rrBs


r)�	metaclassc	Cs|j}|tks"|tkr|tks"dSz|j}t|�}Wntttfk
rRd}YnX|d}zxt�	d|||||�|dkr�|�
||||||�nB|dkr�|�
|||||�n&|dkr�|�
||||�ntd|��Wn*tk
r�t�
td|||||�YnXdS)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�headersZmod_freqZmod_ver�content_typer
r
r�run_partYs^���
���r?cCsdti}t||dd||�dS�Nr/)�
CONTENT_STARTr?�r9r:rr=r
r
r�
call_begin�s�rCcCsdti}t||dd||�dSr@)�CONTENT_ENDr?rBr
r
r�call_end�s�rEc
	Cs�|d}t|}|d}tj�|dd|�}|�d�s@d|}t�||d�|d}z<tt�	|��}	t
|	|d	|�|j|	d
d�|d|d<Wn$tk
r�t�
td
||�YnXdS)NZhandlercountrZ
handlerdirz%sz.pyz%s.pyi��handlersr:T)Zinitializedr.z7Failed at registering python file: %s (part handler %s))�PART_HANDLER_FN_TMPL�os�path�join�endswithrZ
write_file�
fixup_handlerr�
import_modulerC�registerr7r8r5)
ZpdataZ_ctypeZ	_filenamer<Zcurcount�modnamerZmodfnamerFr9r
r
r�walker_handle_handler�s(
�rPcCs�z\t|t�r|�dd�d}n$|dd|�jdd��dd�d}t|�|krZ|d|�}Wn tk
r||d|�}YnX|S)N�
r.r��ignore)�errors)�
isinstance�str�split�decoder�UnicodeDecodeError)Zblob�size�startr
r
r�_extract_first_or_bytes�s
$r\cCsbz|�d�WSttfk
rJz|�d�WYStk
rDYnXYntk
r\YnX|S)NZ
string_escapeZunicode_escape)�encode�LookupErrorr2r4)�textr
r
r�_escape_string�s
r`cCs�|d}||�d�kr&t�d|�dS|tkr@t||||�dS|d}||krpt|||d|||d|�nN|r�t|d�}dt|�}|tkr�t�	d	||�q�t�	d
||�nt�d|�dS)Nr/Zexcludedzcontent_type "%s" is excludedrFr:r�z'%s...'z)Unhandled non-multipart (%s) userdata: %sz0Unhandled unknown content-type (%s) userdata: %szEmpty payload of type %s)
�getr5r6�PART_CONTENT_TYPESrPr?r\r`�NOT_MULTIPART_TYPE�warning)r:r;r<r=r>rFr[Zdetailsr
r
r�walker_callback�s@�
��rfc	Cs�d}|��D]t}|��dkrq|��}|dkr2t}|��}|sFt|}t|�}t�|�||d<t	�
|�}|||||�|d}qdS)NrZ	multipartr/r.)�walkZget_content_maintypeZget_content_type�
OCTET_TYPE�get_filename�PART_FN_TPL�dictr5r6rZfully_decoded_payload)	�msg�callbackr:Zpartnum�partZctyper;r=r<r
r
rrgs 

rgcCsRt|d�st|dd�t|d�s.t|d|�n |j}|rN|tkrNt�d||�|S)Nrr.rz&Handler %s has an unknown frequency %s)r"�setattrrrr5re)r9Zdef_freqZfreqr
r
rrLs

rLcCsXzt�|���}Wntk
r*|YSX|��}tD]}|�|�r8t|Sq8|Sr)rZ
decode_binary�lowerrY�lstrip�INCLUSION_SRCH�
startswithr)r<�defaultZ
payload_lcr_r
r
r�type_from_starts_with#s

ru)N)'r+ZloggingrHZ	cloudinitrrrZcloudinit.settingsrrrZ	getLoggerr(r5rdrhrDrAZCONTENT_SIGNALSrcrGrjr�sorted�list�keysrr�ABCMetarr?rCrErPr\r`rfrgrLrur
r
r
r�<module>sR
�
�0)