[python-win32] Wanted to know how we can overwrite the win32serviceutil.ServiceFramework SvcDoRun method.

Tim Roberts timr at probo.com
Thu Mar 29 19:07:35 CEST 2012


pavi ena wrote:
>
> I am new to Python Window services development. I have small code below.
> ...
> Generally i run this script as batch file which takes parameters like
> user_id
> and password
>
> python demo_svcs.py install
> python demo_svcs.py start %user_id% %password%
>
> At present in my code i am passing user_id and password as argv
>  "win32serviceutil.HandleCommandLine(DemoService, argv=sys.argv)"
>  which intern i am accessing these user_id and password in 'SvcDoRun'
> method
>  with 'args', i just wanted to know is this the correct approach or do
> we have flexibility
>  to overwrite 'SvcDoRun' method to get these 'user_id' and 'password'
> as kwd_args
>  and use these kwd_args in 'start_mail_check' method.

Remember that you have the full source code to win32serviceutil.py in
your Python distribution.  You can go look it up.  SvcDoRun is called
from win32serviceutil.py.  You'll see that it is called from
ServiceFramework.SvcRun with no parameters:
    self.SvcDoRun()

SvcRun is called in response to a message from the Service Control
Manager, so there's really no place to make a modification like that.  I
think you need to keep doing what you are doing.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list