views:

12

answers:

0

I have a python program which can either act as an executable or Windows service, depending on command-line flags (e.g., -s start would launch it as a service). I'm trying to bundle this as an exe using py2exe, which works all fine and well until I try to start the program as a service. Then, I get the classic "unable to respond" error. Now, http://stackoverflow.com/questions/996129/py2exe-windows-service-problem provides a fix for that, but in the process ends up breaking my app's ability to run as an executable. Searching around, I found this gem of a paragraph in the py2exe documentation:

Optionally, you can specify a 'cmdline-style' attribute to py2exe, with valid values being 'py2exe' (the default), 'pywin32' or 'custom'.... 'custom' means that your module is expected to provide a 'HandleCommandLine' function which is responsible for all command-line handling.

While this may or may not do what I want, I have no idea what a 'cmdline-style' attribute is and how I can 'specify' such an attribute, so cannot test it.

So the question is: can I create an executable that can also act as a service in py2exe (depending on the command-line flags)? A follow-up question: can someone give an example of how to "specify a 'cmdline-style' attribute to py2exe"?