a „oe¼ã@s†dZddlZddlZddlZddlZejZe ejej¡Z ddd„Z ddd„Z dej dddfdd „Z dd d „Zdd d „Zddd„ZdS)z1Event Log Utilities - helper for win32evtlog.pyd éNÚ ApplicationcCs²|durtj}t tjd||f¡}t |ddtj|¡|durRtjtj Btj B}t |ddtj |¡|dkr¤|dur|tj}t |ddtj|¡t |ddtj |¡t  |¡dS)a&Add a source of messages to the event log. Allows Python program to register a custom source of messages in the registry. You must also provide the DLL name that has the message table, so the full message text appears in the event log. Note that the win32evtlog.pyd file has a number of string entries with just "%1" built in, so many Python programs can simply use this DLL. Disadvantages are that you do not get language translation, and the full text is stored in the event log, blowing the size of the log up. Nú0SYSTEM\CurrentControlSet\Services\EventLog\%s\%sÚEventMessageFilerZTypesSupportedZCategoryMessageFileZ CategoryCount) Ú win32evtlogÚ__file__Úwin32apiZ RegCreateKeyÚwin32conÚHKEY_LOCAL_MACHINEZ RegSetValueExÚ REG_EXPAND_SZÚEVENTLOG_ERROR_TYPEZEVENTLOG_WARNING_TYPEZEVENTLOG_INFORMATION_TYPEÚ REG_DWORDÚ RegCloseKey)ÚappNameZmsgDLLÚ eventLogTypeZ eventLogFlagsZ categoryDLLZ categoryCountÚhkey©rú:C:\Program Files\Certbot\pkgs\win32\lib\win32evtlogutil.pyÚAddSourceToRegistrys^ÿþû ÿþÿûûûrc CsTzt tjd||f¡Wn4tjyN}z|jtjkr:‚WYd}~n d}~00dS)z0Removes a source of messages from the event log.rN)rZ RegDeleteKeyrr ÚerrorÚwinerrorZERROR_FILE_NOT_FOUND)rrÚexcrrrÚRemoveSourceFromRegistry`sÿþ rc Cs0t d|¡}t |||||||¡t |¡dS)z4Report an event for a previously added event source.N)rZRegisterEventSourceÚ ReportEventZDeregisterEventSource)rZeventIDZ eventCategoryZ eventTypeÚstringsÚdataZsidZhAppLogrrrros ù rc CsØd||jf}t tj|¡}z¦t |d¡d d¡}d}|D]x}zRt |¡}t |dtj ¡}z&t  tj ||j t |j¡}Wt |¡n t |¡0Wntjy¦Yn0|dur<q¶q) r&rrr"ÚjoinrZ HRESULT_CODEr r)r#r$ZdescrrrÚSafeFormatMessage¿s    ýÿÿr(c Csh|durtjtjB}t ||¡}z6t ||d¡}|s6qJt|fdd„|ƒq"Wt |¡n t |¡0dS)NrcSs ||fŽS)Nr)ÚitemÚfeederrrrÚãóz%FeedEventLogRecords..)rZEVENTLOG_BACKWARDS_READZEVENTLOG_SEQUENTIAL_READZ OpenEventLogZ ReadEventLogÚmapZ CloseEventLog)r*Z machineNameZlogNameZ readFlagsÚhZobjectsrrrÚFeedEventLogRecordsÖs ÿ r/)NrNNr)r)r)N)NrN)Ú__doc__rrrrrZ MAKELANGIDZ LANG_NEUTRALZSUBLANG_NEUTRALr!rrr rr&r(r/rrrrÚs.ú R ù  5 ÿ