예제 #1
0
 def test_event_log_from_good_string(self):
     self.assertTrue(
         isinstance(
             event_logs.event_log(LOG_NAME),
             event_logs.EventLog
         )
     )
예제 #2
0
 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()
예제 #3
0
 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()
예제 #4
0
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
예제 #5
0
 def test_event_log_from_bad_string(self):
     with self.assertRaises(event_logs.x_event_logs):
         event_logs.event_log ("")
예제 #6
0
 def test_event_log_from_none(self):
     self.assertTrue(event_logs.event_log(None) is None)
예제 #7
0
 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
예제 #8
0
 def test_event_log_from_good_string(self):
     self.assertTrue(
         isinstance(event_logs.event_log(LOG_NAME), event_logs.EventLog))
예제 #9
0
 def test_event_log_from_none(self):
     self.assertTrue(event_logs.event_log(None) is None)
예제 #10
0
 def test_event_log_from_bad_string(self):
     with self.assertRaises(event_logs.x_event_logs):
         event_logs.event_log("")
예제 #11
0
 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
예제 #12
0
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
예제 #13
0
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)
예제 #14
0
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)
예제 #15
0
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")
)