[Python-au] win32 services from py2exe

Darryl Ross spam at afoyi.com
Thu Mar 9 05:54:04 CET 2006


Hey All,

I'm having trouble building (well, running really) a win32 service using
py2exe. I'm hoping someone here can help...

Here's my service class:

> # ==========================================================================
> # Win32 Service Support
> # ==========================================================================
> import win32serviceutil
> import win32service
> import win32event
> 
> class PollingService(win32serviceutil.ServiceFramework):
>     _svc_name_ = 'oeg-dtms-polling'
>     _svc_display_name_ = 'oeg-dtms-polling'
> 
>     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):
>         main()
> # ==========================================================================

That is at the bottom of a larger file that includes the definition for
main().

My setup.py looks like:

> from distutils.core import setup
> import py2exe
> 
> from lib import constants
> 
> def run():
>     setup(
>         name = constants.APP_NAME,
>         version = constants.VERSION,
>         description = constants.APP_DESC,
>         author = constants.APP_AUTHOR,
>         author_email = constants.APP_AUTHOR_EMAIL,
>         url = constants.APP_URL,
>         service = [{
>                      'modules': 'polling_service',
>                      'icon_resources': [(1, 'dtms.ico')],
>                   }],
>         zipfile = None,
>         options = {
>             'py2exe' : {
>                 'compressed' : 1,
>                 'optimize' : 2
>             }
>         }
>      )
> 
> 
> 
> if __name__ == '__main__':
>     run()

After building it, it installs ok, but won't run:

> Z:\dist>polling_service.exe -install
> 
> Z:\dist>net start oeg-dtms-polling
> System error 3 has occurred.
> 
> The system cannot find the path specified.

I'm guessing that I'm doing something fairly obviously wrong, but I
can't see what it is. Anyone have any ideas?

TIA,
Darryl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 208 bytes
Desc: OpenPGP digital signature
Url : http://starship.python.net/pipermail/python-au/attachments/20060309/6a8e8b6c/signature.pgp


More information about the python-au mailing list