本文整理汇总了Python中win32service.SC_MANAGER_CONNECT属性的典型用法代码示例。如果您正苦于以下问题:Python win32service.SC_MANAGER_CONNECT属性的具体用法?Python win32service.SC_MANAGER_CONNECT怎么用?Python win32service.SC_MANAGER_CONNECT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类win32service
的用法示例。
在下文中一共展示了win32service.SC_MANAGER_CONNECT属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import SC_MANAGER_CONNECT [as 别名]
def __init__(self,plugin):
"""
This initializes the class, and saves the plugin reference for use in the new thread.
"""
self.plugin = plugin
self.file = None
self.connecting = False
self.receiving = False
self.sentMessageOnce = True
self.receivingTimeout = None
try:
scmanager = win32service.OpenSCManager(None, None, win32service.SC_MANAGER_CONNECT)
self.service = win32service.OpenService(scmanager, MCE_SERVICE_NAME, win32service.SERVICE_START | win32service.SERVICE_QUERY_STATUS)
win32service.CloseServiceHandle(scmanager)
except:
self.service = None
示例2: QueryServiceStatus
# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import SC_MANAGER_CONNECT [as 别名]
def QueryServiceStatus(serviceName, machine=None):
hscm = win32service.OpenSCManager(machine,None,win32service.SC_MANAGER_CONNECT)
try:
hs = SmartOpenService(hscm, serviceName, win32service.SERVICE_QUERY_STATUS)
try:
status = win32service.QueryServiceStatus(hs)
finally:
win32service.CloseServiceHandle(hs)
finally:
win32service.CloseServiceHandle(hscm)
return status
示例3: _get_service_control_manager
# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import SC_MANAGER_CONNECT [as 别名]
def _get_service_control_manager(
scm_access=win32service.SC_MANAGER_CONNECT):
hscm = win32service.OpenSCManager(None, None, scm_access)
try:
yield hscm
finally:
win32service.CloseServiceHandle(hscm)
示例4: _get_service_handle
# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import SC_MANAGER_CONNECT [as 别名]
def _get_service_handle(service_name,
service_access=win32service.SERVICE_QUERY_CONFIG,
scm_access=win32service.SC_MANAGER_CONNECT):
with WindowsUtils._get_service_control_manager(scm_access) as hscm:
hs = win32service.OpenService(hscm, service_name, service_access)
try:
yield hs
finally:
win32service.CloseServiceHandle(hs)
示例5: is_agent_running
# 需要导入模块: import win32service [as 别名]
# 或者: from win32service import SC_MANAGER_CONNECT [as 别名]
def is_agent_running(self, fail_if_running=False, fail_if_not_running=False):
"""Returns true if the agent service is running, as determined by this platform implementation.
This will optionally raise an Exception with an appropriate error message if the agent is running or not
runnning.
@param fail_if_running: True if the method should raise an Exception with a platform-specific error message
explaining how it determined the agent is running.
@param fail_if_not_running: True if the method should raise an Exception with a platform-specific error message
explaining how it determined the agent is not running.
@type fail_if_running: bool
@type fail_if_not_running: bool
@return: True if the agent process is already running.
@rtype: bool
@raise AgentAlreadyRunning
@raise AgentNotRunning
"""
hscm = None
hs = None
try:
hscm = win32service.OpenSCManager(
None, None, win32service.SC_MANAGER_CONNECT
)
hs = win32serviceutil.SmartOpenService(
hscm, _SCALYR_AGENT_SERVICE_, win32service.SERVICE_QUERY_STATUS
)
status = win32service.QueryServiceStatusEx(hs)
state = status["CurrentState"]
is_running = state in (
win32service.SERVICE_RUNNING,
win32service.SERVICE_START_PENDING,
)
if fail_if_running and is_running:
pid = status["ProcessId"]
raise AgentAlreadyRunning(
"The operating system reports the Scalyr Agent Service is running with "
"pid=%d" % pid
)
if fail_if_not_running and not is_running:
raise AgentNotRunning(
"The operating system reports the Scalyr Agent Service is not running"
)
return state in (
win32service.SERVICE_RUNNING,
win32service.SERVICE_START_PENDING,
)
finally:
if hs is not None:
win32service.CloseServiceHandle(hs)
if hscm is not None:
win32service.CloseServiceHandle(hscm)