problem with python win32 and win32evtlog

Mark Hammond mhammond at skippinet.com.au
Mon May 19 20:48:56 EDT 2003


Konrad Mauz wrote:

> Hello,
> 
> I'me trying to write a script to summerize an win2k eventlog.
> 
> I thought, with the following code, all events in "system" on
> host "sam" should be in the list "allevents".
> But only 6 events are in the list.
> The win2k eventlog contains more the hundred entries.
> 
> Is there something wrong with my code?
> 
> I'am using Python 2.2.2 python win32 extension build 150
> on win2k german version.
> 
> Here the the relevant part of code:
> 
> --schnipp--
> #
> #
> import win32evtlog
> import time
> 
> system_handle=win32evtlog.OpenEventLog("SAM", "System")
> flags=win32evtlog.EVENTLOG_BACKWARDS_READ|win32evtlog.EVENTLOG_SEQUENTIAL_READ
> allevents=win32evtlog.ReadEventLog(system_handle, flags,0)
> 
> print len(allevents)
> --schnapp--

Add the ReadEventLog call in a loop, like:
   while 1:
     events = win32evtlog.ReadEventLog(system_handle, flags,0)
     if not events:
        break
     print events

Mark.





More information about the Python-list mailing list