Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'value,': 0.04; 'subject:Python': 0.06; 'url:msdn': 0.07; 'here?': 0.09; 'key.': 0.09; 'overflow': 0.09; 'wrapper': 0.09; 'translate': 0.10; 'api': 0.11; 'python': 0.11; 'itself.': 0.14; 'language.': 0.14; "wouldn't": 0.14; "(i'm": 0.16; 'from:addr:timgolden.me.uk': 0.16; 'from:name:tim golden': 0.16; 'golden': 0.16; 'internally': 0.16; 'intrinsic': 0.16; 'message-id:@timgolden.me.uk': 0.16; 'object;': 0.16; 'python-list,': 0.16; 'rather,': 0.16; 'reads,': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'subject:library': 0.16; 'such,': 0.16; 'tjg': 0.16; 'underlying': 0.16; 'url:85)': 0.16; 'wmi': 0.16; 'wrappers': 0.16; 'do,': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'stack': 0.19; '>>>': 0.22; 'example': 0.22; 'import': 0.22; 'header:User- Agent:1': 0.23; 'error': 0.23; 'exists': 0.24; 'received:192.168.100': 0.24; 'looks': 0.24; 'skip:" 30': 0.26; 'somewhere': 0.26; 'asking': 0.27; 'skip:" 20': 0.27; 'header:In- Reply-To:1': 0.27; 'chris': 0.29; 'external': 0.29; 'am,': 0.29; 'raise': 0.29; 'tim': 0.29; "doesn't": 0.30; 'forgot': 0.30; 'list:': 0.30; 'url:mailman': 0.30; '(which': 0.31; 'code': 0.31; 'getting': 0.31; 'usually': 0.31; '>>>>': 0.31; 'file': 0.32; 'interface': 0.32; 'another': 0.32; 'url:python': 0.33; '(most': 0.33; 'entirely': 0.33; 'maybe': 0.34; 'could': 0.34; "can't": 0.35; 'knows': 0.35; 'beyond': 0.35; 'case,': 0.35; 'more,': 0.35; 'objects': 0.35; 'but': 0.35; 'there': 0.35; 'url:listinfo': 0.36; 'thanks': 0.36; "i'll": 0.36; 'hi,': 0.36; 'url:org': 0.36; 'wrong': 0.37; 'too': 0.37; 'url:microsoft': 0.37; 'list': 0.37; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'list,': 0.38; 'little': 0.38; 'anything': 0.39; 'recent': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'mailing': 0.39; 'either': 0.39; 'url:mail': 0.40; 'how': 0.40; 'skip:u 10': 0.60; 'skip:c 50': 0.60; 'tell': 0.60; 'free': 0.61; "you're": 0.61; 'first': 0.61; 'back': 0.62; 'kind': 0.63; 'such': 0.63; 'pick': 0.64; 'more': 0.64; 'different': 0.65; 'taking': 0.65; 'linked': 0.65; 'details': 0.65; 'here': 0.66; 'hang': 0.67; 'forums': 0.68; 'url:en-us': 0.68; 'skip:w 30': 0.69; 'receive': 0.70; 'services.': 0.70; 'url:%1': 0.72; 'from:addr:mail': 0.83; '2015': 0.84; 'are)': 0.84; 'hard.': 0.84 Date: Tue, 07 Apr 2015 16:18:09 +0100 From: Tim Golden User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Python library - WMI.py RegistryValueChangeEvent References: <02021a54-2770-4072-808a-75bea346051d@googlegroups.com> <5b5fd1cb-484f-4798-b10c-4903ad7aa65c@googlegroups.com> <82e021c9-d375-454f-8a01-c21305e36e6f@googlegroups.com> <5523EF3B.6060705@timgolden.me.uk> In-Reply-To: <5523EF3B.6060705@timgolden.me.uk> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 78 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1428419908 news.xs4all.nl 2907 [2001:888:2000:d::a6]:39493 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88591 On 07/04/2015 15:52, Tim Golden wrote: > On 07/04/2015 15:35, Khyati wrote: >> On Tuesday, April 7, 2015 at 10:31:47 AM UTC-4, Chris Angelico wrote: >>> On Wed, Apr 8, 2015 at 12:15 AM, Khyati wrote: >>>> Thanks for taking a look, Chris. >>>> The error trace: >>>> traceback (most recent call last): >>>> File "MonitorRegistry.py", line 18, in >>>> process_created = watcher() >>>> File "C:\Python27\lib\site-packages\wmi.py", line 1195, in __call__ >>>> handle_com_error () >>>> File "C:\Python27\lib\site-packages\wmi.py", line 241, in handle_com_error >>>> raise klass (com_error=err) >>>> _wmi: >>> >>> It looks to me like this is a thin wrapper around the underlying API >>> call, and you're getting back an error from the lower-level services. >>> The way this reads, there might well not be an >>> HKLM\Software\Temp\Name; maybe the ValueName is what's wrong here? >>> >>> Someone somewhere knows more than I do, but if you can't find that >>> someone here on python-list, you might be able to find some help on >>> Stack Overflow or another mailing list, from people who know how to do >>> this kind of thing in a different language. You'd have to translate >>> their suggestions back into Python, but when the wrappers are thin >>> enough, that's usually not too hard. >>> >>> ChrisA >> >> HKLM\Software\Temp\Name exists since the event is caught correctly only when I change that key. >> i'll keep looking :) >> > > Hi, Khyati. > > Unfortunately, extrinsic events don't come with much information. As you > can see from the MSDN description: > > https://msdn.microsoft.com/en-us/library/aa390355%28v=vs.85%29.aspx > > they're not linked to WMI objects internally (which the intrinsic events > are) so all they can do is echo back to you details of what changed -- > which will usually be the thing you were asking about in the first place! > > So the Python wrapper doesn't receive any TargetInstance because it's > not a *WMI* event as such, linked to a WMI object; rather, it's an > external event which has provided a hook for WMI to hang on to. > > In this specific case, you could use the WMI Registry provider to pick > up the current value of that registry value, but that wouldn't tell you > what was there before or anything else. In another case, the event might > be about some entirely external system -- such as the > SecurityViolationEvent in the MSDN example -- which provides no WMI > interface beyond the event itself. > > Feel free to ask more, either on this list or on the win32-specific > Python list: > > https://mail.python.org/mailman/listinfo/python-win32 > > (I'm not often free to answer questions so best to use the public forums > where more people will be able to help). Forgot to say: you can simplify your code a little as well: import wmi c = wmi.WMI(namespace="root/default") watcher = c.RegistryValueChangeEvent(Hive="HKEY_LOCAL_MACHINE", KeyPath=r"Software\\Temp", ValueName="Name") event = watcher() TJG