本文整理汇总了Python中win32serviceutil.StopService方法的典型用法代码示例。如果您正苦于以下问题:Python win32serviceutil.StopService方法的具体用法?Python win32serviceutil.StopService怎么用?Python win32serviceutil.StopService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32serviceutil
的用法示例。
在下文中一共展示了win32serviceutil.StopService方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: signal_child
# 需要导入模块: import win32serviceutil [as 别名]
# 或者: from win32serviceutil import StopService [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: stop_agent_service
# 需要导入模块: import win32serviceutil [as 别名]
# 或者: from win32serviceutil import StopService [as 别名]
def stop_agent_service(self, quiet):
"""Stops the agent service using the platform-specific method.
This method must return only after the agent service has terminated.
@param quiet: True if only error messages should be printed to stdout, stderr.
@type quiet: bool
"""
try:
if not quiet:
print("Sending control signal to stop agent service.")
win32serviceutil.StopService(_SCALYR_AGENT_SERVICE_)
if not quiet:
print("Agent service has stopped.")
except win32api.error as e:
if e[0] == winerror.ERROR_SERVICE_NOT_ACTIVE:
raise AgentNotRunning(
"The operating system indicates the Scalyr Agent Service is not running."
)
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
示例3: svcStop
# 需要导入模块: import win32serviceutil [as 别名]
# 或者: from win32serviceutil import StopService [as 别名]
def svcStop( svc_name, machine=None):
status = win32serviceutil.StopService( svc_name, machine)[1]
while status == STOPPING:
time.sleep(1)
status = svcStatus( svc_name, machine)
return status
示例4: _StopProcess
# 需要导入模块: import win32serviceutil [as 别名]
# 或者: from win32serviceutil import StopService [as 别名]
def _StopProcess(self):
win32serviceutil.StopService(self.service, self.machine)
while win32serviceutil.QueryServiceStatus(self.service, self.machine)[1] == 3:
time.sleep(0.25)
if win32serviceutil.QueryServiceStatus(self.service, self.machine)[1] != 1:
raise Exception("WindowsService: Unable to stop service!")