本文整理匯總了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!")