473,624 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 DispatchWithEve nts() 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(objec t):
def OnObjectReady(s elf, *args): #self may be the wmi_sink object
print "OnObjectRe ady callback ..."
print self #.TargetInstanc e.Message
print args[0]

def OnCompleted(sel f, *args):
print "OnComplete d callback..."
print args #.TargetInstanc e.Message

def OnObjectPut(sel f, *args):
print "OnObjectPu t callback..."

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

wmi = win32com.client .GetObject("win mgmts:
{impersonationL evel=impersonat e,(security)}!//./root/cimv2")
wmi_sink =
win32com.client .DispatchWithEv ents("WbemScrip ting.SWbemSink" ,SinkClass)
wmi.ExecNotific ationQueryAsync (wmi_sink,"SELE CT * FROM
__InstanceCreat ionEvent where TargetInstance ISA 'Win32_NTLogEve nt'")
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 3008

<ha*********@ya hoo.comwrote in message news:11******** *************@2 2g2000hsm.googl egroups.com...
I'm trying to get a notification from the NT event for any new event
using the DispatchWithEve nts() 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(objec t):
def OnObjectReady(s elf, *args): #self may be the wmi_sink object
print "OnObjectRe ady callback ..."
print self #.TargetInstanc e.Message
print args[0]

def OnCompleted(sel f, *args):
print "OnComplete d callback..."
print args #.TargetInstanc e.Message

def OnObjectPut(sel f, *args):
print "OnObjectPu t callback..."

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

wmi = win32com.client .GetObject("win mgmts:
{impersonationL evel=impersonat e,(security)}!//./root/cimv2")
wmi_sink =
win32com.client .DispatchWithEv ents("WbemScrip ting.SWbemSink" ,SinkClass)
wmi.ExecNotific ationQueryAsync (wmi_sink,"SELE CT * FROM
__InstanceCreat ionEvent where TargetInstance ISA 'Win32_NTLogEve nt'")
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(s elf, *args): #self may be the wmi_sink object
print "OnObjectRe ady callback ..."
print self #.TargetInstanc e.Message
wbem_object=win 32com.client.ge ncache.EnsureDi spatch(args[0],0)
print wbem_object
ti=wbem_object. Properties_('Ta rgetInstance'). 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
12566
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)"; document.getElementById('myelement') = new Function("myfnc(param1,param2,param3)");
18
2876
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 that applies to all these events, but I need to have specific code execute when the form closes. The properties for this method are sender (the originator) and e (event arguments). I know how to get typeof (sender) to determine what form or...
4
4905
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'); window.resizeTo(810,750); top.outerWidth=810;
4
4164
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 when I got myself hocked on it for real and now I love C# _and_ Python. But there is something that keeps bugging me, and that keeps me from embracing Python even more as a serious alternative to C#(for me). In C# I make heavy use of Get & Set,...
17
10187
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
1428
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 property for each database object and load its value into it. Thus, in my database (which is an oodbms) say I have a MyDbaseClass with MyProperty1, MyProperty2, etc, after it is loaded, I have:
0
798
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 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...
17
2769
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 Bad. So maybe we've got over that. I suppose properties could have Bad consequences if a user doesn't know they exist and think that a certain property of an object is just an ordinary attribute. But that applies to
4
9844
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 this context, in fact some articles from pre-2.0 suggest using any collection class of your choice. So my questions focus more on the syntax of event properties provided by the "event" keyword in C#. (Disclaimer - I am a C++ programmer working...
0
8240
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8680
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8336
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7168
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6111
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4082
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2610
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.