[python-win32] Installing a Python script as service

Mark Hammond mhammond at skippinet.com.au
Sat Aug 27 06:08:05 CEST 2005


Oops - I missed the original - thanks Roger!

I've now changed that check to:

        if os.path.splitext(win32service.__file__)[0].endswith("_d"):

Mark
  -----Original Message-----
  From: python-win32-bounces at python.org
[mailto:python-win32-bounces at python.org]On Behalf Of Roger Upole
  Sent: Saturday, 27 August 2005 11:51 AM
  To: python-win32 at python.org
  Subject: Re: [python-win32] Installing a Python script as service


  The intent is to register the service to run in debug mode if you're
currently
  running a debug build.  By convention, pyd's and exe's have _d appended
  to them for a debug build, so you'd have win32service_d.pyd.
  It would be more reliable to use os.path.splitext and check that the last
  2 chars are _d rather than doing .find on the whole path.

       hth
           Roger

    Hi

    We have the following problem when we try to install a Python script as
Win32 service:

    The Python script is located in a path that contains the substring
"_demonstrator". When installing the Python service for this script, we get
the error message, the the file "PythonService_d.exe" isn't found. We don't
have this file in our Python installation. First investigations led us to
the following lines at win32serviceutil.py:

    def LocatePythonServiceExe(exeName = None):
        # Try and find the specified EXE somewhere.  If specifically
registered,
        # use it.  Otherwise look down sys.path, and the global PATH
environment.
        if exeName is None:
            if win32service.__file__.find("_d")>=0:
                exeName = "PythonService_d.exe"
            else:
                exeName = "PythonService.exe"
       ...

    This function is called to find the executable for the Python service to
store it at registry when the Python service is installed. The call to
find("_d") returns with >0 in our case, because our path contains the
substring "_demonstrator". I don't understand what the meaning of this lines
is. Why is the decission for correct PythonService exe made on the substring
"_d"? This is not very save, I think.

    Can anybody explain this?

    An easy workaround is to avoid the substring "_d" in the path to the
Python script that should be installed as PythonService. But is it realy
intended to forbid "_d" substrings in paths for PythonServices when we don't
want to run in PythonService_d.exe? How can this be ensured in real world?
Maybe there should be another criteria for the decision which PythonService
exe is taken.

    Regards,
    Wolfgang


----------------------------------------------------------------------------


    _______________________________________________
    Python-win32 mailing list
    Python-win32 at python.org
    http://mail.python.org/mailman/listinfo/python-win32
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20050827/df70eb80/attachment-0001.htm


More information about the Python-win32 mailing list