def test_event_log_from_good_string(self): self.assertTrue( isinstance( event_logs.event_log(LOG_NAME), event_logs.EventLog ) )
def test_event_log_clear_with_save(self): log_name = "Internet Explorer" source_name = "_winsys-%s" % uuid.uuid1() source = event_logs.EventSource.create(source_name, log_name) log = event_logs.event_log(log_name) hLog = win32evtlog.OpenEventLog(None, log_name) try: log.log_event(source, message="hello") self.assertNotEquals(win32evtlog.GetNumberOfEventLogRecords(hLog), 0) log.clear() self.assertEqual(win32evtlog.GetNumberOfEventLogRecords(hLog), 0) finally: win32evtlog.CloseEventLog(hLog) source.delete()
def remote_events(computer, event_source, event_type_id): for event in event_logs.event_log(r"\\%s\system" % computer): if event.source_name.upper( ) == event_source and event.event_type == event_type_id: yield event
def test_event_log_from_bad_string(self): with self.assertRaises(event_logs.x_event_logs): event_logs.event_log ("")
def test_event_log_from_none(self): self.assertTrue(event_logs.event_log(None) is None)
def test_event_log_from_event_log(self): for l in event_logs.event_logs(): self.assertTrue(isinstance(l, event_logs.EventLog)) self.assertTrue(event_logs.event_log(l) is l) break
def test_event_log_from_good_string(self): self.assertTrue( isinstance(event_logs.event_log(LOG_NAME), event_logs.EventLog))
def test_event_log_from_bad_string(self): with self.assertRaises(event_logs.x_event_logs): event_logs.event_log("")
def remote_events (computer, event_source, event_type_id): for event in event_logs.event_log (r"\\%s\system" % computer): if event.source_name.upper () == event_source and event.event_type == event_type_id: yield event
from __future__ import with_statement import os import csv from winsys import dialogs, event_logs log_name, filename = dialogs.dialog( "Write event log to csv", ("Event log", list(event_logs.event_logs())), ("CSV filename", ""), ) namer = event_logs.EVENTLOG_TYPE.name_from_value with open(filename, "wb") as f: csv.writer(f).writerows( (e.time_generated, e.source_name, namer(e.event_type), e.message) for e in event_logs.event_log(log_name)) os.startfile(filename)
from __future__ import with_statement import os import csv from winsys import dialogs, event_logs log_name, filename = dialogs.dialog( "Write event log to csv", ("Event log", list(event_logs.event_logs())), ("CSV filename", ""), ) namer = event_logs.EVENTLOG_TYPE.name_from_value with open(filename, "wb") as f: csv.writer(f).writerows( (e.time_generated, e.source_name, namer(e.event_type), e.message) for e in event_logs.event_log(log_name) ) os.startfile(filename)
import csv from winsys import event_logs csv.writer (open ("06.csv", "wb")).writerows ( (event.record_number, event.time_generated, event.event_id, event.message) for event in event_logs.event_log ("system") )