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


Python win32serviceutil.ControlService方法代碼示例

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


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

示例1: signal_child

# 需要導入模塊: import win32serviceutil [as 別名]
# 或者: from win32serviceutil import ControlService [as 別名]
def signal_child(service, command):
    if command == 'stop':
        win32serviceutil.StopService(service)
    elif command == 'restart':
        win32serviceutil.RestartService(service)
    else:
        win32serviceutil.ControlService(service, control_codes[command]) 
開發者ID:cherrypy,項目名稱:cherrypy,代碼行數:9,代碼來源:win32.py

示例2: request_agent_status

# 需要導入模塊: import win32serviceutil [as 別名]
# 或者: from win32serviceutil import ControlService [as 別名]
def request_agent_status(self):
        """Invoked by a process that is not the agent to request the current agent dump the current detail
        status to the status file.

        This is used to implement the 'scalyr-agent-2 status -v' feature.

        @return: If there is an error, an errno that describes the error.  errno.EPERM indicates the current does not
            have permission to request the status.  errno.ESRCH indicates the agent is not running.
        """
        try:
            win32serviceutil.ControlService(
                _SCALYR_AGENT_SERVICE_, _SERVICE_CONTROL_DETAILED_REPORT_
            )
        except win32api.error as e:
            if e[0] == winerror.ERROR_SERVICE_NOT_ACTIVE:
                return errno.ESRCH
            elif e[0] == winerror.ERROR_SERVICE_DOES_NOT_EXIST:
                raise AgentNotRunning(
                    "The operating system indicates the Scalyr Agent Service is not installed.  "
                    "This indicates a failed installation.  Try reinstalling the agent."
                )
            else:
                raise e 
開發者ID:scalyr,項目名稱:scalyr-agent-2,代碼行數:25,代碼來源:platform_windows.py


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