473,402 Members | 2,046 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,402 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 2999

<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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.