event log - Python WINEVTLOG Open Backup Logs -
i attempting use openbackupeventlog("",file) open eventlogs saved on cdrom. going through loop load each file under subdirectory. have 2 issues @ moment.
1. script pull first file name , output events on screen, when reach end not reset. 2. when goes through second position of list gives error of file not found.
import win32evtlog e = os.listdir('d:\\somedir\\anotherdir\\') item in range(len(e)): handle = win32evtlog.openbackupeventlog("none", e[item]) flags = win32evtlog.eventlog_backwards_read|win32evtlog.eventlog_sequential_read total = e.getnumberofeventlogrecords(handle) print "total events are: ", total while true: event_list = win32evtlog.readeventlog(handle, flags, 0) if event_list: event in event_list: info = (event.eventtype, event.timegenerated, event.sourcename, event.eventid) print info
any appreciated; it's can't close connection on win32evtlog. have used win32evtlog.closeeventlog(handle).
few items causing issue:
- cdrom or cd erroring out; have copy files temp directory , process them.
- no break @ end of loop; if not event: break
Comments
Post a Comment