Ñò
àÎŠ@c           @   sÊ   d  Z  d d k Z d d k Z d d k Z d d k Z d d k Z e i Z e i e i e i	 ƒ Z
 d d d d „ Z d d „ Z d e i d d d d „ Z d d „ Z d d	 „ Z d d d d
 „ Z d S(   s1   Event Log Utilities - helper for win32evtlog.pyd
iÿÿÿÿNt   Applicationc         C   sª   | d j o t i } n t i t i d | |  f ƒ } t i | d d t i | ƒ | d j o t i	 t i
 Bt i B} n t i | d d t i | ƒ t i | ƒ d S(   s&  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.
    s0   SYSTEM\CurrentControlSet\Services\EventLog\%s\%st   EventMessageFilei    t   TypesSupportedN(   t   Nonet   win32evtlogt   __file__t   win32apit   RegCreateKeyt   win32cont   HKEY_LOCAL_MACHINEt   RegSetValueExt   REG_EXPAND_SZt   EVENTLOG_ERROR_TYPEt   EVENTLOG_WARNING_TYPEt   EVENTLOG_INFORMATION_TYPEt	   REG_DWORDt   RegCloseKey(   t   appNamet   msgDLLt   eventLogTypet   eventLogFlagst   hkey(    (    sI   C:\graphics\Tools\Python26\Lib\site-packages\win32\lib\win32evtlogutil.pyt   AddSourceToRegistry
   s"    		c         C   s`   y! t  i t i d | |  f ƒ Wn8 t  i j
 o) \ } } } | t i j o ‚  q\ n Xd S(   s5   Removes a source of messages from the event log.
    s0   SYSTEM\CurrentControlSet\Services\EventLog\%s\%sN(   R   t   RegDeleteKeyR   R	   t   errort   winerrort   ERROR_FILE_NOT_FOUND(   R   R   t   hrt   fnt   desc(    (    sI   C:\graphics\Tools\Python26\Lib\site-packages\win32\lib\win32evtlogutil.pyt   RemoveSourceFromRegistry6   s    i    c         C   sB   t  i d |  ƒ } t  i | | | | | | | ƒ t  i | ƒ d S(   s9   Report an event for a previously added event source.
    N(   R   t   RegisterEventSourceR   t   ReportEventt   DeregisterEventSource(   R   t   eventIDt   eventCategoryt	   eventTypet   stringst   datat   sidt   hAppLog(    (    sI   C:\graphics\Tools\Python26\Lib\site-packages\win32\lib\win32evtlogutil.pyR    C   s    	c         C   s  d | |  i  f } t i t i | ƒ } zÉ t i | d ƒ d i d ƒ } d } x | D]• } yd t i | ƒ } t i	 | d t i
 ƒ } z( t i t i | |  i t |  i ƒ } Wd t i | ƒ XWn t i j
 o n X| d j	 o PqW qW WWd t i | ƒ X| p d S(   s-  Given a tuple from ReadEventLog, and optionally where the event
    record came from, load the message, and process message inserts.

    Note that this function may raise win32api.error.  See also the
    function SafeFormatMessage which will return None if the message can
    not be processed.
    s0   SYSTEM\CurrentControlSet\Services\EventLog\%s\%sR   i    t   ;Nu    (   t
   SourceNameR   t
   RegOpenKeyR   R	   t   RegQueryValueExt   splitR   t   ExpandEnvironmentStringst   LoadLibraryExt   DONT_RESOLVE_DLL_REFERENCESt   FormatMessageWt   FORMAT_MESSAGE_FROM_HMODULEt   EventIDt   langidt   StringInsertst   FreeLibraryR   R   (   t   eventLogRecordt   logTypet   keyNamet   handlet   dllNamesR&   t   dllNamet	   dllHandle(    (    sI   C:\graphics\Tools\Python26\Lib\site-packages\win32\lib\win32evtlogutil.pyt   FormatMessageT   s(     c         C   sŽ   | d j o
 d } n y t |  | ƒ SWn_ t i j
 oP |  i d j o
 d } n d i |  i ƒ } d t i |  i ƒ |  i	 | f SXd S(   sc   As for FormatMessage, except returns an error message if
    the message can not be processed.
    R    t    u   , u|   <The description for Event ID ( %d ) in Source ( %r ) could not be found. It contains the following insertion string(s):%r.>N(
   R   R>   R   R   R5   t   joinR   t   HRESULT_CODER3   R*   (   R7   R8   R   (    (    sI   C:\graphics\Tools\Python26\Lib\site-packages\win32\lib\win32evtlogutil.pyt   SafeFormatMessage~   s     

c         C   s†   | d  j o t i t i B} n t i | | ƒ } z> x7 t i | | d ƒ } | p Pn t |  d „ | ƒ q9 Wd  t i | ƒ Xd  S(   Ni    c         S   s   t  | |  f ƒ S(    (   t   apply(   t   itemt   feeder(    (    sI   C:\graphics\Tools\Python26\Lib\site-packages\win32\lib\win32evtlogutil.pyt   <lambda>–   s    (   R   R   t   EVENTLOG_BACKWARDS_READt   EVENTLOG_SEQUENTIAL_READt   OpenEventLogt   ReadEventLogt   mapt   CloseEventLog(   RE   t   machineNamet   logNamet	   readFlagst   ht   objects(    (    sI   C:\graphics\Tools\Python26\Lib\site-packages\win32\lib\win32evtlogutil.pyt   FeedEventLogRecordsŒ   s    (   t   __doc__R   R   R   R   t   stringR   t
   MAKELANGIDt   LANG_NEUTRALt   SUBLANG_NEUTRALR4   R   R   R   R   R    R>   RB   RR   (    (    (    sI   C:\graphics\Tools\Python26\Lib\site-packages\win32\lib\win32evtlogutil.pyt   <module>   s   <	,*