本文整理汇总了Python中win32serviceutil.HandleCommandLine方法的典型用法代码示例。如果您正苦于以下问题:Python win32serviceutil.HandleCommandLine方法的具体用法?Python win32serviceutil.HandleCommandLine怎么用?Python win32serviceutil.HandleCommandLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32serviceutil
的用法示例。
在下文中一共展示了win32serviceutil.HandleCommandLine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
# 需要导入模块: import win32serviceutil [as 别名]
# 或者: from win32serviceutil import HandleCommandLine [as 别名]
def start(self):
"""Starting the daemon based on platform
Returns:
bool: start success
"""
plat = platform.system().lower()
if plat.startswith("win"):
# Windows
win32serviceutil.HandleCommandLine(AppServerSvc, argv=['grease', 'start'])
return True
elif plat.startswith("dar"):
# MacOS
if subprocess.call(["sudo", "launchctl", "load", "/Library/LaunchDaemons/net.grease.daemon.plist"]) != 0:
return False
return True
elif plat.startswith("lin"):
# Linux
if subprocess.call(["sudo", "systemctl", "start", "grease"]) != 0:
return False
return True
else:
self.ioc.getLogger().error("Unrecognized operating system [{0}]".format(platform))
return False
示例2: stop
# 需要导入模块: import win32serviceutil [as 别名]
# 或者: from win32serviceutil import HandleCommandLine [as 别名]
def stop(self):
"""Stopping the daemon based on the platform
Returns:
bool: stop success
"""
plat = platform.system().lower()
if plat.startswith("win"):
# Windows
win32serviceutil.HandleCommandLine(AppServerSvc, argv=['grease', 'stop'])
return True
elif plat.startswith("dar"):
if subprocess.call(["sudo", "launchctl", "unload", "/Library/LaunchDaemons/net.grease.daemon.plist"]) != 0:
return False
# MacOS
return True
elif plat.startswith("lin"):
# Linux
if subprocess.call(["sudo", "systemctl", "stop", "grease"]) != 0:
return False
return True
else:
self.ioc.getLogger().error("Unrecognized operating system [{0}]".format(platform))
return False
示例3: parse_command_line
# 需要导入模块: import win32serviceutil [as 别名]
# 或者: from win32serviceutil import HandleCommandLine [as 别名]
def parse_command_line(cls):
'''
ClassMethod to parse the command line
'''
win32serviceutil.HandleCommandLine(cls)
示例4: windows_service
# 需要导入模块: import win32serviceutil [as 别名]
# 或者: from win32serviceutil import HandleCommandLine [as 别名]
def windows_service(service_args, res_circuits_args):
"""Register a windows service"""
try:
import win32serviceutil
from resilient_circuits.bin import service_wrapper
if res_circuits_args:
# Set the command line arguments to pass to "resilient-circuits.exe run"
service_wrapper.irms_svc.setResilientArgs(res_circuits_args)
sys.argv = sys.argv[0:1] + service_args
win32serviceutil.HandleCommandLine(service_wrapper.irms_svc)
except ImportError:
LOG.error("Requires PYWIN32 Package. Please download and install from: "
"https://sourceforge.net/projects/pywin32/files/pywin32/")
示例5: __call_service_handler
# 需要导入模块: import win32serviceutil [as 别名]
# 或者: from win32serviceutil import HandleCommandLine [as 别名]
def __call_service_handler():
def __ctrlHandler(ctrlType):
return True
from opsbro.windows_service.windows_service import Service
win32api.SetConsoleCtrlHandler(__ctrlHandler, True)
win32serviceutil.HandleCommandLine(Service)
示例6: ctrlHandler
# 需要导入模块: import win32serviceutil [as 别名]
# 或者: from win32serviceutil import HandleCommandLine [as 别名]
def ctrlHandler(ctrlType):
return True
# if __name__ == '__main__':
# win32api.SetConsoleCtrlHandler(ctrlHandler, True)
# win32serviceutil.HandleCommandLine(Service)