Question

I am currently working on a python program which runs as a windows service using win32service and win32serviceutil. The service runs as it should and even after using py2exe, everything is fine (the service monitors target folder(s) and autmotically FTP's newly created files to specified FTP location). I would like, however, to add some command line arguments (in addition to install, remove, start, stop, etc...) for specifying the local and FTP directories. The only documentation on this is what I found at: http://www.py2exe.org/old/

"Optionally, you can specify a 'cmdline-style' attribute to py2exe, with valid values being 'py2exe' (the default), 'pywin32' or 'custom'. 'py2exe' specifies the traditional command-line always supported by py2exe. 'pywin32' supports the exact same command-line arguments as pywin32 supports (ie, the same arguments supported when running the service from the .py file.) 'custom' means that your module is expected to provide a 'HandleCommandLine' function which is responsible for all command-line handling."

Any help would be appreciated in getting pointed in the right direction. Please let me know if any code is needed for clarity.

Thanks, Zach

Was it helpful?

Solution

here is a nice example of how to make a service with a custom HandleCommandLine classmethod -- it's part of pyro but has no dependencies on pyro, rather it's a utility "abstract base class" that you can subclass and get a service going with minimum fuss by just setting a few things in your subclass. For your specific needs, you can use it as a template to copy and edit to get the command line handling that you want!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top