From: <th...@us...> - 2003-10-28 09:02:27
|
Update of /cvsroot/py2exe/py2exe/sandbox/py2exe/samples In directory sc8-pr-cvs1:/tmp/cvs-serv1241 Modified Files: MyService.py Log Message: Fix the event logging. As Mark explains, the event source can be any string, but we shouldn't be too special in the sample, and use _svc_name_. This also avoids the need to call AddSourceToRegistry (and overwriting the source already added by servicemanager.pyd). Index: MyService.py =================================================================== RCS file: /cvsroot/py2exe/py2exe/sandbox/py2exe/samples/MyService.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MyService.py 1 Oct 2003 19:59:07 -0000 1.1 --- MyService.py 28 Oct 2003 09:00:34 -0000 1.2 *************** *** 21,36 **** _svc_deps_ = ["EventLog"] def __init__(self, args): - import sys - # The exe-file has messages for the Event Log Viewer. - # Register the exe-file as event source. - # - # Probably it would be better if this is done at installation time, - # so that it also could be removed if the service is uninstalled. - # Unfortunately it cannot be done in the 'if __name__ == "__main__"' - # block below, because the 'frozen' exe-file does not run this code. - # - win32evtlogutil.AddSourceToRegistry(self._svc_display_name_, - sys.executable, - "Application") win32serviceutil.ServiceFramework.__init__(self, args) self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) --- 21,24 ---- *************** *** 43,47 **** import servicemanager # Write a 'started' event to the event log... ! win32evtlogutil.ReportEvent(self._svc_display_name_, servicemanager.PYS_SERVICE_STARTED, 0, # category --- 31,35 ---- import servicemanager # Write a 'started' event to the event log... ! win32evtlogutil.ReportEvent(self._svc_name_, servicemanager.PYS_SERVICE_STARTED, 0, # category *************** *** 53,57 **** # and write a 'stopped' event to the event log. ! win32evtlogutil.ReportEvent(self._svc_display_name_, servicemanager.PYS_SERVICE_STOPPED, 0, # category --- 41,45 ---- # and write a 'stopped' event to the event log. ! win32evtlogutil.ReportEvent(self._svc_name_, servicemanager.PYS_SERVICE_STOPPED, 0, # category |