[pywin32-checkins] pywin32/win32/Lib win32serviceutil.py,1.15,1.16
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2005-01-31 04:12:08
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19664/win32/Lib Modified Files: win32serviceutil.py Log Message: Add optional service description Index: win32serviceutil.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32serviceutil.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** win32serviceutil.py 27 Sep 2004 21:39:37 -0000 1.15 --- win32serviceutil.py 31 Jan 2005 04:12:00 -0000 1.16 *************** *** 138,142 **** return exeName ! def InstallService(pythonClassString, serviceName, displayName, startType = None, errorControl = None, bRunInteractive = 0, serviceDeps = None, userName = None, password = None, exeName = None, perfMonIni = None, perfMonDll = None, exeArgs = None): # Handle the default arguments. if startType is None: --- 138,142 ---- return exeName ! def InstallService(pythonClassString, serviceName, displayName, startType = None, errorControl = None, bRunInteractive = 0, serviceDeps = None, userName = None, password = None, exeName = None, perfMonIni = None, perfMonDll = None, exeArgs = None, description = None): # Handle the default arguments. if startType is None: *************** *** 165,168 **** --- 165,173 ---- userName, password) + if description is not None: + try: + win32service.ChangeServiceConfig2(hs,win32service.SERVICE_CONFIG_DESCRIPTION,description) + except NotImplementedError: + pass ## ChangeServiceConfig2 and description do not exist on NT win32service.CloseServiceHandle(hs) finally: *************** *** 173,177 **** InstallPerfmonForService(serviceName, perfMonIni, perfMonDll) ! def ChangeServiceConfig(pythonClassString, serviceName, startType = None, errorControl = None, bRunInteractive = 0, serviceDeps = None, userName = None, password = None, exeName = None, displayName = None, perfMonIni = None, perfMonDll = None, exeArgs = None): # Before doing anything, remove any perfmon counters. try: --- 178,182 ---- InstallPerfmonForService(serviceName, perfMonIni, perfMonDll) ! def ChangeServiceConfig(pythonClassString, serviceName, startType = None, errorControl = None, bRunInteractive = 0, serviceDeps = None, userName = None, password = None, exeName = None, displayName = None, perfMonIni = None, perfMonDll = None, exeArgs = None, description = None): # Before doing anything, remove any perfmon counters. try: *************** *** 207,211 **** userName, password, ! displayName) finally: win32service.CloseServiceHandle(hs) --- 212,222 ---- userName, password, ! displayName) ! if description is not None: ! try: ! win32service.ChangeServiceConfig2(hs,win32service.SERVICE_CONFIG_DESCRIPTION,description) ! except NotImplementedError: ! pass ## ChangeServiceConfig2 and description do not exist on NT ! finally: win32service.CloseServiceHandle(hs) *************** *** 562,565 **** --- 573,580 ---- except AttributeError: exeArgs = None + try: + description = cls._svc_description_ + except AttributeError: + description = None print "Installing service %s to Python class %s" % (serviceName,serviceClassString) # Note that we install the service before calling the custom option *************** *** 568,572 **** # we remove the service if the first bit works, but the second doesnt! try: ! InstallService(serviceClassString, serviceName, serviceDisplayName, serviceDeps = serviceDeps, startType=startup, bRunInteractive=interactive, userName=userName,password=password, exeName=exeName, perfMonIni=perfMonIni,perfMonDll=perfMonDll,exeArgs=exeArgs) if customOptionHandler: apply( customOptionHandler, (opts,) ) --- 583,587 ---- # we remove the service if the first bit works, but the second doesnt! try: ! InstallService(serviceClassString, serviceName, serviceDisplayName, serviceDeps = serviceDeps, startType=startup, bRunInteractive=interactive, userName=userName,password=password, exeName=exeName, perfMonIni=perfMonIni,perfMonDll=perfMonDll,exeArgs=exeArgs,description=description) if customOptionHandler: apply( customOptionHandler, (opts,) ) *************** *** 605,611 **** except AttributeError: exeArgs = None print "Changing service configuration" try: ! ChangeServiceConfig(serviceClassString, serviceName, serviceDeps = serviceDeps, startType=startup, bRunInteractive=interactive, userName=userName,password=password, exeName=exeName, displayName = serviceDisplayName, perfMonIni=perfMonIni,perfMonDll=perfMonDll,exeArgs=exeArgs) print "Service updated" except win32service.error, (hr, fn, msg): --- 620,630 ---- except AttributeError: exeArgs = None + try: + description=cls._svc_description_ + except AttributeError: + description=None print "Changing service configuration" try: ! ChangeServiceConfig(serviceClassString, serviceName, serviceDeps = serviceDeps, startType=startup, bRunInteractive=interactive, userName=userName,password=password, exeName=exeName, displayName = serviceDisplayName, perfMonIni=perfMonIni,perfMonDll=perfMonDll,exeArgs=exeArgs,description=description) print "Service updated" except win32service.error, (hr, fn, msg): *************** *** 651,654 **** --- 670,674 ---- _exe_name_ = None # Default to PythonService.exe _exe_args_ = None # Default to no arguments + _svc_description_ = None # Only exists on Windows 2000 or later, ignored on windows NT def __init__(self, args): |