本文整理汇总了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])
示例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