Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Sorry, not enough info to answer your question. This seem an application-specific thing.</p> <p>The only thing I can think is to review the code of win32serviceutil.HandleCommandLine method and WinService class to determine which one writes to the log. Then, you have to make a subclass and override the method responsible to write in the log to receive an additional argument. Finally, you must chance all references from the original class to the new one.</p> <p>-- Added, after the edition of the question.</p> <p>Clearer, but still insufficient. You need to review <em>win32serviceutil.HandleCommandLine</em> and see how it invokes service.WindowsService.LoopService.__init__. In particular, how <em>HandleCommandLine</em> generates <em>args</em> and how you can control it.</p> <p>If you are in a hurry, you can do:</p> <pre><code>class LoopService(win32serviceutil.ServiceFramework): repetitions = 5 # ... def __init__(self,args): win32serviceutil.ServiceFramework.__init__(self,args) self.hWaitStop = win32event.CreateEvent(None,0,0,None) self.repetitions = LoopService.repetitions # ... def SvcDoRun(self): for i in range(self.repetitions): servicemanager.LogInfoMsg("just something to put in the log"); win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE) </code></pre> <p>Then you can control the number of repetition changing LoopService.repetitions <strong>before</strong> creating a new instance.</p> <pre><code>import service.WindowsService, win32serviceutil service.WindowsService.LoopService.repetitions = 10 win32serviceutil.HandleCommandLine(service.WindowsService.LoopService); </code></pre> <p>This works, but it's ugly. Try to control <em>args</em> and then set <em>self.repetition</em> accordingly. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload