Re: Running WMI within a Windows service

2005-06-22 Thread cameron . mccloud
Tim,

Changing the path didn't do anything, but changing the name of the
module to my_wmi did the trick.

Thanks very much,

Cam.

Tim Golden wrote:
 [EMAIL PROTECTED]
 | Hi,
 |
 | When trying to import the WMI module in a Python Windows
 | Service, I get
 | the following:
 |
 | dynamic module does not define init function (initwmi)
 |
 | The WMI version is 0.6. Python 2.4 on Win32, Python Win32 extensions
 | version 203

 This is almost certainly caused by a problem which
 I consistently fail to mention on my site every time
 it comes up. In essence, the service you've defined
 will run in c:\winnt\system32, where there is an
 file called wmi.dll (which presumably implements
 the core WMI functionality). Python, looking for
 a wmi to import, finds this -- which could be
 a Python module -- and tries to import it. And fails.

 Possible solutions:

 1) Within the service code, switch directories to
some other directory before importing wmi.

 2) Rename wmi.py to something else (pywmi.py?)
and import that.

 3) Run the service as a named user, which will run
within that user's home directory. (Not at all
sure about this one; haven't tried it).

 HTH
 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
 

-- 
http://mail.python.org/mailman/listinfo/python-list


Running WMI within a Windows service

2005-06-21 Thread cameron . mccloud
Hi,

When trying to import the WMI module in a Python Windows Service, I get
the following:

dynamic module does not define init function (initwmi)

The WMI version is 0.6. Python 2.4 on Win32, Python Win32 extensions
version 203

Code below,

Cam.

def SvcDoRun(self):

import servicemanager
servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, ''))
print Running...

try:
import wmi
print module imported
except Exception, e:
print exception:  + str(e)

print Stopped.
self.ReportServiceStatus(win32service.SERVICE_STOPPED)
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STOPPED,
(self._svc_name_, EventMonSvc stopping... )
)

-- 
http://mail.python.org/mailman/listinfo/python-list