[python-win32] Can't import wmi in scripts run by nrpe_nt

Jan Van Uytven (Wyvern) wyvernlist at crm3.com
Wed Oct 27 21:02:49 CEST 2004


On Wed, 2004-10-27 at 08:25 +0100, Tim Golden wrote:
> | BTW, I'd like to congratulate you on wmi. If it weren't so 
> | useful to me I wouldn't be trying to solve this problem.
> 
> Thanks for the bouquet. In fact, the people who really deserve
> congratulations are the MS team who put the WMI stuff together,
> and Mark H and the other contributors to pywin32. All I've
> done is put some lightweight plumbing in place to make the
> whole experience a little easier to cope with.

I noticed Mark Hammond posts to this newsgroup too. Thanks Mark, and all
other contributors, for making life easier for the beleagured
sysadmin! :)

> 
> | I'm sorry, I could have phrased this better.
> 
> That's all right; your explanation below (snipped) makes
> it perfectly clear. I suspect the problem is that the nrpe_nt
> process runs as a service. There is (probably) a .dll called
> wmi in your windows system directory. When the service runs,
> it probably runs as the system user in the system directory.
> When it imports wmi, it actually tries to import the wmi.dll
> (which is nothing to do with Python, but rather to do with
> wmi itself). It either fails nicely or bombs completely,
> depending slightly on what version of Python you're running.
> 
> Two possible solutions, both quite simple:
> 
> a) Run the service outside the c:\winnt\system32 (or whatever)
>    directory. Or at least do an os.chdir before importing wmi.
> b) Rename wmi.py on that machine to pywmi.py (or whatever other
>    name takes your fancy) and try again.
> 
> Let me know if that helps
> 

Roger pointed this out too, and is indeed the problem. Thanks! I'll see
if it's possible to get the nrpe_nt service to run in another directory,
and failing that use the os.chdir trick you suggested. :)

Thanks again for your help :)


> TJG
> 
> ________________________________________________________________________
> This e-mail has been scanned for all viruses by Star. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
> ________________________________________________________________________
> _______________________________________________
> Python-win32 mailing list
> Python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
---
Jan Van Uytven
Computer Systems & Network Engineer
Convergent Media Network
wyvern at crm3.com

Randomly selected from my quote-file:

Men in their arrogance claim to understand the nature of creation,
and devise elaborate theories to describe its behavior. But always
they discover in the end that God was quite a bit more clever than
they thought.
         -- Sister Miriam Godwinson,
            "We Must Dissent"


>>> LEGAL STUFF <<< 
This electronic message transmission, including any attached files, 
contains information which may be confidential and/or privileged.
The information is intended to be for the SOLE use of the individual or 
entity named above. If you are not the intended recipient, be aware 
that any review, disclosure, copying, distribution or use of the 
contents of this information is prohibited. This message is not to be 
forwarded for any reason without prior consent of the sender. 

If you have received this electronic transmission in error, please 
notify the sender immediately by telephone (250) 386-4266 or by a 
'reply to sender only' message and destroy all electronic and hard 
copies of the communication, including attachments, without reading 
or saving in any manner.



More information about the Python-win32 mailing list