473,395 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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.

Oct 11 '07 #1
1 2998

<ha*********@yahoo.comwrote in message news:11*********************@22g2000hsm.googlegrou ps.com...
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.
The first arg is passed as a raw IDispatch interface. You can wrap it
as below to access the properties.

def OnObjectReady(self, *args): #self may be the wmi_sink object
print "OnObjectReady callback ..."
print self #.TargetInstance.Message
wbem_object=win32com.client.gencache.EnsureDispatc h(args[0],0)
print wbem_object
ti=wbem_object.Properties_('TargetInstance').Value
print 'TargetInstance',ti
for p in ti.Properties_:
print p.Name, p.Value
Roger


----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Oct 13 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Eric | last post by:
How can I dynamically assign an event to an element? I have tried : (myelement is a text input) document.getElementById('myelement').onKeyUp = "myfnc(param1,param2,param3)"; ...
18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
4
by: Pai | last post by:
hello there, I am trying to rersize the window it works find in IE but doea not work with mozilla window.attachEvent(onload,MWSOnLoad); window.onload = function (MWSOnLoad) { alert('hello');...
4
by: Varghjärta | last post by:
Hey! I'm a hobby programmer since many years now and I've done most of my latest 'real application' coding in C#. I've played with python of and on yet not catching on until a few months ago...
17
by: dan_williams | last post by:
I have the following test web page:- <html> <head><title>Test</title> <script language="Javascript"> <!-- function fnTR() { alert("TR"); }
6
by: manstey | last post by:
I have a ClassWrapper that wraps around a third party database object. Each database object has a set of properties, like columns in a relational database. I want my wrapper to generate a...
0
by: hainguyen2x | last post by:
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...
17
by: David C. Ullrich | last post by:
Having a hard time phrasing this in the form of a question... The other day I saw a thread where someone asked about overrideable properties and nobody offered the advice that properties are...
4
by: FullBandwidth | last post by:
I have been perusing various blogs and MSDN pages discussing the use of event properties and the EventHandlerList class. I don't believe there's anything special about the EventHandlerList class in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.