Re: Multiple windows services on the same machine

2011-06-06 Thread Mark Hammond

On 6/06/2011 2:54 AM, Massi wrote:

Hi everyone, I'm writing a script which implement a windows service
with the win32serviceutil module. The service works perfectly, but now
I would need to install several instances of the same service on my
machine for testing purpose.
This is hard since the service name is hard-coded in the service class
definition:

class MyService(win32serviceutil.ServiceFramework) :
 _svc_name_ = 'MyService'
 _svc_display_name_ = 'Instance ofMyService'


It is only hard-coded in the HandleCommandLine function - you probably 
just want your own argv parsing and call InstallService directly.


HTH,

Mark
--
http://mail.python.org/mailman/listinfo/python-list


Re: Multiple windows services on the same machine

2011-06-05 Thread Ben Finney
Massi  writes:

> So can anyone point me out which is the best way to "parametrize" the
> service name? Thanks in advance for your help!

Could you not make the ‘_svc_display_name’ an instance attribute instead
of class attribute?

That is, don't set it as an attribute on the class; instead, set it as
an attribute on the instance during initialisation (the ‘__init__’
method).

-- 
 \ “Smoking cures weight problems. Eventually.” —Steven Wright |
  `\   |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Multiple windows services on the same machine

2011-06-05 Thread Massi
Hi everyone, I'm writing a script which implement a windows service
with the win32serviceutil module. The service works perfectly, but now
I would need to install several instances of the same service on my
machine for testing purpose.
This is hard since the service name is hard-coded in the service class
definition:

class MyService(win32serviceutil.ServiceFramework) :
_svc_name_ = 'MyService'
_svc_display_name_ = 'Instance ofMyService'

def __init__(self, args) :
win32serviceutil.ServiceFramework.__init__(self, args)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)

def SvcStop(self) :
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
sys.stopservice = "true"
win32event.SetEvent(self.hWaitStop)

def SvcDoRun(self) :
#Do something...

So can anyone point me out which is the best way to "parametrize" the
service name? Thanks in advance for your help!
-- 
http://mail.python.org/mailman/listinfo/python-list