how to get the NT event log properties with OnObjectReady() with python

hainguyen2x at yahoo.com hainguyen2x at yahoo.com
Thu Oct 11 12:40:10 EDT 2007


I'm trying to get a notification from the NT event for any new event
using the DispatchWithEvents() function. Everything seems to be
working the way I wanted, but I don't know how to get the properties
of the event (ie. event type, message, etc.) from the OnObjectReady()
callback.

class SinkClass(object):
    def OnObjectReady(self, *args): #self may be the wmi_sink object
        print "OnObjectReady callback ..."
        print self #.TargetInstance.Message
        print args[0]

    def OnCompleted(self, *args):
        print "OnCompleted callback..."
        print args #.TargetInstance.Message

    def OnObjectPut(self, *args):
        print "OnObjectPut callback..."

    def OnProgress(self, *args):
        print "OnProgress callback..."

wmi = win32com.client.GetObject("winmgmts:
{impersonationLevel=impersonate,(security)}!//./root/cimv2")
wmi_sink =
win32com.client.DispatchWithEvents("WbemScripting.SWbemSink",SinkClass)
wmi.ExecNotificationQueryAsync(wmi_sink,"SELECT * FROM
__InstanceCreationEvent where TargetInstance ISA 'Win32_NTLogEvent'")


The argument args in the OnObjectReady() seems to be the interface to
a com object (may be the event object itself).
I want to read the properties (ie. message, eventID, type, etc)  of
the triggered NT event.

Please help.




More information about the Python-list mailing list