As mentioned previously in this chapter,
PythonService.exe hosts all Python programs
running as services. Once this host .exe is
running, it makes a module
available to the Python program. Because your Python scripts are used
both by Python.exe (when installing, starting,
or debugging the service) and by
PythonService.exe (when running as a service),
you can’t import this module from the top level of your Python
servicemanager statement will fail for
Python.exe. In practice, this means you should
only import this module locally to a function.
The primary purpose of
servicemanager is to
provide facilities for interacting with the SCM at runtime. Most of
this interaction is done by the base class
win32serviceutil.ServiceFramework(), so in general
this is covered for you.
There are, however, some useful utility functions you may wish to
use. Among these is a set of functions for writing to the Event Log.
The most general purpose is the function
, which takes the following parameters:
EVENT-LOG_WARNING_TYPE. These constants can be
The message ID. This uniquely identifies the message text.
Inserts = None
A list of string inserts for the message or
The inserts are merged with the message text to provide the final
result for the user.
There are three other Event Log-related functions in this module.