64K #ˆl–ß=¿J µ2ÛR‚œP-\l˜´o ƒy÷ÁÀ¿#a '¡Dg$ã@sàdZddlZddlZddlZddlZddlmZddlm Z ddl m Z m Z ddl mZdZdZd Ze e¡ZGd d „d eƒZed ƒZGd d„dƒZGdd„deƒZddd„Zejdfdd„Zdd„ZGdd„dƒZdd„ZdS)z� events for reporting. The events here are designed to be used with reporting. They can be published to registered handlers with report_event. éN)ÚList)Ú performance)Úavailable_handlersÚinstantiated_handler_registry)ÚReportingHandlerZfinishÚstartÚ cloudinitc@seZdZdd„ZdS)Ú_namesetcCs||vr |Std|ƒ‚dS)Nz%s not a valid value)ÚAttributeError)ÚselfÚname©r ú>/usr/lib/python3.9/site-packages/cloudinit/reporting/events.pyÚ __getattr__ sz_nameset.__getattr__N)Ú__name__Ú __module__Ú __qualname__rr r r rr sr )ÚSUCCESSÚWARNÚFAILc@s.eZdZdZedfdd„Zdd„Zdd„ZdS) ÚReportingEventz"Encapsulation of event formatting.NcCs2||_||_||_||_|dur(t ¡}||_dS©N)Ú event_typer Ú descriptionÚoriginÚtimeÚ timestamp)r rr rrrr r rÚ__init__,szReportingEvent.__init__cCsd |j|j|j¡S)z"The event represented as a string.z {0}: {1}: {2})Úformatrr r©r r r rÚ as_string<s ÿzReportingEvent.as_stringcCs|j|j|j|j|jdœS)z&The event represented as a dictionary.©r rrrrr!rr r rÚas_dictBs ûzReportingEvent.as_dict)rrrÚ__doc__ÚDEFAULT_EVENT_ORIGINrr r"r r r rr)s ú rcs8eZdZejdf‡fdd„ Zdd„Z‡fdd„Z‡ZS)ÚFinishReportingEventNcsDtt|ƒ t||¡||_|dur&g}||_|tvr@td|ƒ‚dS)NzInvalid result: %s)Úsuperr%rÚFINISH_EVENT_TYPEÚresultÚ post_filesÚstatusÚ ValueError)r r rr(r)©Ú __class__r rrNs ÿzFinishReportingEvent.__init__cCsd |j|j|j|j¡S)Nz{0}: {1}: {2}: {3})rrr r(rrr r rr [sÿzFinishReportingEvent.as_stringcs0tt|ƒ ¡}|j|d<|jr,t|jƒ|d<|S)z'The event represented as json friendly.r(Úfiles)r&r%r"r(r)Ú_collect_file_info)r Údatar,r rr"`s  zFinishReportingEvent.as_dict) rrrr*rrr r"Ú __classcell__r r r,rr%Msÿ r%csTˆsi‰‡fdd„tj ¡Dƒ}ttj ¡ƒ}|D]}t|ƒ|vrDq2| |¡q2dS)a¯Report an event to all registered event handlers except those whose type is in excluded_handler_types. This should generally be called via one of the other functions in the reporting module. :param excluded_handler_types: List of handlers types to exclude from reporting the event to. :param event_type: The type of the event; this should be a constant from the reporting module. csh|]\}}|ˆvr|’qSr r )Ú.0Z hndl_typeZhndl_cls©Úexcluded_handler_typesr rÚ ysþzreport_event..N)rZregistered_itemsÚitemsÚlistrÚvaluesÚtypeZ publish_event)Úeventr4Zexcluded_handler_classesÚhandlersZhandlerr r3rÚ report_eventis þÿ r<cCst||||d�}t|ƒS)zVReport a "finish" event. See :py:func:`.report_event` for parameter details. ©r))r%r<)Ú event_nameÚevent_descriptionr(r)r:r r rÚreport_finish_eventˆsÿr@c