Python WINEVTLOG 打开备份日志
我正在尝试使用 OpenBackupEventLog("",file) 打开保存在 CDrom 上的事件日志。我正在经历一个循环来加载子目录下的每个文件。我现在有两个问题。
1. 脚本将拉取第一个文件名并在屏幕上输出事件,但是当它们到达末尾时,它不会重置。 2. 当它遍历列表的第二个位置时,会给出文件未找到的错误。
import win32evtlog
e = os.listdir('D:\\SomeDir\\AnotherDir\\')
for 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:
for event in event_list:
info = (event.EventType,
event.TimeGenerated,
event.SourceName,
event.EventID)
print info
任何帮助表示赞赏;就像我无法关闭与 win32evtlog 的连接。我使用了 win32evtlog.CloseEventLog(handle)。
I am attempting to use the OpenBackupEventLog("",file) to open eventlogs which are saved on a CDrom. I am going through a loop to load each file under the subdirectory. I have two issues at the moment.
1. The script will pull the first file name and output events on screen, however when they reach the end it does not reset.
2. When it goes through the second position of the list it gives an error of file not found.
import win32evtlog
e = os.listdir('D:\\SomeDir\\AnotherDir\\')
for 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:
for event in event_list:
info = (event.EventType,
event.TimeGenerated,
event.SourceName,
event.EventID)
print info
Any help is appreciated; It's like I can't close the connection on with win32evtlog. I have used the win32evtlog.CloseEventLog(handle).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
导致我的问题的几个因素:
Few items which were causing my issue: