當前位置: 首頁>>代碼示例>>Python>>正文


Python servicemanager.LogMsg方法代碼示例

本文整理匯總了Python中servicemanager.LogMsg方法的典型用法代碼示例。如果您正苦於以下問題:Python servicemanager.LogMsg方法的具體用法?Python servicemanager.LogMsg怎麽用?Python servicemanager.LogMsg使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在servicemanager的用法示例。


在下文中一共展示了servicemanager.LogMsg方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: SvcOtherEx

# 需要導入模塊: import servicemanager [as 別名]
# 或者: from servicemanager import LogMsg [as 別名]
def SvcOtherEx(self, control, event_type, data):
        # This is only showing a few of the extra events - see the MSDN
        # docs for "HandlerEx callback" for more info.
        if control == win32service.SERVICE_CONTROL_DEVICEEVENT:
            info = win32gui_struct.UnpackDEV_BROADCAST(data)
            msg = "A device event occurred: %x - %s" % (event_type, info)
        elif control == win32service.SERVICE_CONTROL_HARDWAREPROFILECHANGE:
            msg = "A hardware profile changed: type=%s, data=%s" % (event_type, data)
        elif control == win32service.SERVICE_CONTROL_POWEREVENT:
            msg = "A power event: setting %s" % data
        elif control == win32service.SERVICE_CONTROL_SESSIONCHANGE:
            # data is a single elt tuple, but this could potentially grow
            # in the future if the win32 struct does
            msg = "Session event: type=%s, data=%s" % (event_type, data)
        else:
            msg = "Other event: code=%d, type=%s, data=%s" \
                  % (control, event_type, data)

        servicemanager.LogMsg(
                servicemanager.EVENTLOG_INFORMATION_TYPE,
                0xF000, #  generic message
                (msg, '')
                ) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:25,代碼來源:serviceEvents.py

示例2: SvcDoRun

# 需要導入模塊: import servicemanager [as 別名]
# 或者: from servicemanager import LogMsg [as 別名]
def SvcDoRun(self):
        servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
                              servicemanager.PYS_SERVICE_STARTED,
                              (self._svc_name_, ''))
        self.isAlive = True
        # Create new threads
        self.main() 
開發者ID:AutohomeRadar,項目名稱:Windows-Agent,代碼行數:9,代碼來源:agent.py

示例3: SvcDoRun

# 需要導入模塊: import servicemanager [as 別名]
# 或者: from servicemanager import LogMsg [as 別名]
def SvcDoRun(self):
        # Write an event log record - in debug mode we will also
        # see this message printed.
        servicemanager.LogMsg(
                servicemanager.EVENTLOG_INFORMATION_TYPE,
                servicemanager.PYS_SERVICE_STARTED,
                (self._svc_name_, '')
                )

        num_connections = 0
        while 1:
            pipeHandle = CreateNamedPipe("\\\\.\\pipe\\PyPipeTest",
                    PIPE_ACCESS_DUPLEX| FILE_FLAG_OVERLAPPED,
                    PIPE_TYPE_MESSAGE | PIPE_READMODE_BYTE,
                    PIPE_UNLIMITED_INSTANCES,       # max instances
                    0, 0, 6000,
                    self.CreatePipeSecurityObject())
            try:
                hr = ConnectNamedPipe(pipeHandle, self.overlapped)
            except error, details:
                print "Error connecting pipe!", details
                CloseHandle(pipeHandle)
                break
            if hr==winerror.ERROR_PIPE_CONNECTED:
                # Client is already connected - signal event
                SetEvent(self.overlapped.hEvent)
            rc = WaitForMultipleObjects((self.hWaitStop, self.overlapped.hEvent), 0, INFINITE)
            if rc==WAIT_OBJECT_0:
                # Stop event
                break
            else:
                # Pipe event - spawn thread to deal with it.
                thread.start_new_thread(self.ProcessClient, (pipeHandle,))
                num_connections = num_connections + 1

        # Sleep to ensure that any new threads are in the list, and then
        # wait for all current threads to finish.
        # What is a better way? 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:40,代碼來源:pipeTestService.py

示例4: SvcDoRun

# 需要導入模塊: import servicemanager [as 別名]
# 或者: from servicemanager import LogMsg [as 別名]
def SvcDoRun(self):
        # do nothing at all - just wait to be stopped
        win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE)
        # Write a stop message.
        servicemanager.LogMsg(
                servicemanager.EVENTLOG_INFORMATION_TYPE,
                servicemanager.PYS_SERVICE_STOPPED,
                (self._svc_name_, '')
                ) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:11,代碼來源:serviceEvents.py

示例5: SvcDoRun

# 需要導入模塊: import servicemanager [as 別名]
# 或者: from servicemanager import LogMsg [as 別名]
def SvcDoRun(self):
        '''
        Called when the service is asked to start
        '''
        self.start()
        servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
                              servicemanager.PYS_SERVICE_STARTED,
                              (self._svc_name_, ''))
        self.main() 
開發者ID:frappe,項目名稱:biometric-attendance-sync-tool,代碼行數:11,代碼來源:SMWinservice.py

示例6: SvcDoRun

# 需要導入模塊: import servicemanager [as 別名]
# 或者: from servicemanager import LogMsg [as 別名]
def SvcDoRun(self):
        servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
                              servicemanager.PYS_SERVICE_STARTED,
                              (self._svc_name_, ''))
        servicemanager.LogInfoMsg('ceajenkins before main')
        try:
            self.main()
        except:
            servicemanager.LogErrorMsg(traceback.format_exc())
            sys.exit(-1)
        servicemanager.LogInfoMsg('normal exit') 
開發者ID:architecture-building-systems,項目名稱:CityEnergyAnalyst,代碼行數:13,代碼來源:ceajenkins.py

示例7: SvcDoRun

# 需要導入模塊: import servicemanager [as 別名]
# 或者: from servicemanager import LogMsg [as 別名]
def SvcDoRun(self):
        try:
            LOG('SvcDoRun')
            import servicemanager
            servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, ''))
            servicemanager.LogInfoMsg("OpsBro Start")

            # Set as english
            locale.setlocale(locale.LC_ALL, 'English_Australia.1252')
            
            # under service, stdout and stderr are not available
            # TODO: enable debug mode?
            self.destroy_stdout_stderr()
            LOG('BEFORE CLI')
            # simulate CLI startup with config parsing
            from opsbro.log import cprint, logger, is_tty
            from opsbro.cli import CLICommander, save_current_binary
            from opsbro.yamlmgr import yamler
            
            with open('c:\\opsbro\\etc\\agent.yml', 'r') as f:
                buf = f.read()
                CONFIG = yamler.loads(buf)

            LOG('CONF LOADED')
            
            # Load config
            CLI = CLICommander(CONFIG, None)
            
            LOG('CLI LOADED')
            l = Launcher(cfg_dir='c:\\opsbro\\etc')
            LOG('LAUNCHER created, launching init & main')
            # Note: before launch the start/main, we need to start a stopper thread (on the main process)
            l.do_daemon_init_and_start(is_daemon=False, before_start_callback=self._before_start_callback)
            LOG('LAUNCHER init')
            # called when we're being shut down
        except Exception:
            err = traceback.format_exc()
            LOG('CRASH: %s' % err)
            logger_crash.error(err)
            raise 
開發者ID:naparuba,項目名稱:opsbro,代碼行數:42,代碼來源:windows_service.py

示例8: SvcDoRun

# 需要導入模塊: import servicemanager [as 別名]
# 或者: from servicemanager import LogMsg [as 別名]
def SvcDoRun(self):
            servicemanager.LogMsg(
                servicemanager.EVENTLOG_INFORMATION_TYPE,
                servicemanager.PYS_SERVICE_STARTED,
                (self._svc_name_, '')
            )
            self.main() 
開發者ID:target,項目名稱:grease,代碼行數:9,代碼來源:DaemonCmd.py


注:本文中的servicemanager.LogMsg方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。