[python-win32] Service: path to .py script
Mark Hammond
mhammond at skippinet.com.au
Wed Sep 20 01:48:05 CEST 2006
Is Y: a mappyed network drive? If so, the problem will be that the mapping
does not exist for the service account (and if you are using LocalSystem, it
will not be possible/sensible to add it)
Mark
> -----Original Message-----
> From: python-win32-bounces+mhammond=keypoint.com.au at python.org
> [mailto:python-win32-bounces+mhammond=keypoint.com.au at python.org]On
> Behalf Of Gregor Horvath
> Sent: Tuesday, 19 September 2006 9:27 PM
> To: python-win32 at python.org
> Subject: [python-win32] Service: path to .py script
>
>
> Hi,
>
> I have a testservice.py (see below). I installed the service
> successfully. (via commandlineoption install)
> The problem is that it runs only when it is in
> c:\windows\system32 or in
> the python path.
> I added the desired path (Y:\) to the PYTHONPATH environment variable
> for the system account and rebooted.
> When I start command line python and do a import testservice
> everything
> is fine.
> Starting the service with the script only in Y:\ gives the
> error in the
> event log:
>
> Python could not import the service's module
>
> exceptions.ImportError: No module named testservice
>
> Thanks for your help.
>
> --
> Greg
>
> testservice.py:
>
> import win32serviceutil, win32service
> import servicemanager
> import win32api
> import win32event
> import sys
>
> class TestPipeService(win32serviceutil.ServiceFramework):
> _svc_name_ = "MDE Dispatcher"
> _svc_display_name_ = "MDE-Dispatcher"
> _svc_description_ = "Dispatches machine events from the
> Siemens ODC
> to registrered MDE clients (windows) over the network via XML-RPC"
> def __init__(self, args):
> win32serviceutil.ServiceFramework.__init__(self, args)
> self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
>
> def SvcStop(self):
> self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
> win32event.SetEvent(self.hWaitStop)
>
>
> def SvcDoRun(self):
> # Write an event log record - in debug mode we will also
> # see this message printed.
> servicemanager.LogMsg(
> servicemanager.EVENTLOG_INFORMATION_TYPE,
> servicemanager.PYS_SERVICE_STARTED,
> (self._svc_name_, '')
> )
>
> while 1:
> win32api.Sleep(2)
> rc = win32event.WaitForSingleObject(self.hWaitStop, 2000)
> if rc == win32event.WAIT_OBJECT_0:
> break
>
>
> # Write another event log record.
> servicemanager.LogMsg(
> servicemanager.EVENTLOG_INFORMATION_TYPE,
> servicemanager.PYS_SERVICE_STOPPED,
> (self._svc_name_, " TEST ")
> )
>
>
> if __name__=='__main__':
> win32serviceutil.HandleCommandLine(TestPipeService)
>
>
>
>
>
>
> _______________________________________________
> Python-win32 mailing list
> Python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
More information about the Python-win32
mailing list