本文整理汇总了Python中servicemanager.LogMsg方法的典型用法代码示例。如果您正苦于以下问题:Python servicemanager.LogMsg方法的具体用法?Python servicemanager.LogMsg怎么用?Python servicemanager.LogMsg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类servicemanager
的用法示例。
在下文中一共展示了servicemanager.LogMsg方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SvcOtherEx
# 需要导入模块: import servicemanager [as 别名]
# 或者: from servicemanager import LogMsg [as 别名]
def SvcOtherEx(self, control, event_type, data):
# This is only showing a few of the extra events - see the MSDN
# docs for "HandlerEx callback" for more info.
if control == win32service.SERVICE_CONTROL_DEVICEEVENT:
info = win32gui_struct.UnpackDEV_BROADCAST(data)
msg = "A device event occurred: %x - %s" % (event_type, info)
elif control == win32service.SERVICE_CONTROL_HARDWAREPROFILECHANGE:
msg = "A hardware profile changed: type=%s, data=%s" % (event_type, data)
elif control == win32service.SERVICE_CONTROL_POWEREVENT:
msg = "A power event: setting %s" % data
elif control == win32service.SERVICE_CONTROL_SESSIONCHANGE:
# data is a single elt tuple, but this could potentially grow
# in the future if the win32 struct does
msg = "Session event: type=%s, data=%s" % (event_type, data)
else:
msg = "Other event: code=%d, type=%s, data=%s" \
% (control, event_type, data)
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
0xF000, # generic message
(msg, '')
)
示例2: SvcDoRun
# 需要导入模块: import servicemanager [as 别名]
# 或者: from servicemanager import LogMsg [as 别名]
def SvcDoRun(self):
servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_, ''))
self.isAlive = True
# Create new threads
self.main()
示例3: SvcDoRun
# 需要导入模块: import servicemanager [as 别名]
# 或者: from servicemanager import LogMsg [as 别名]
def SvcDoRun(self):
# Write an event log record - in debug mode we will also
# see this message printed.
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_, '')
)
num_connections = 0
while 1:
pipeHandle = CreateNamedPipe("\\\\.\\pipe\\PyPipeTest",
PIPE_ACCESS_DUPLEX| FILE_FLAG_OVERLAPPED,
PIPE_TYPE_MESSAGE | PIPE_READMODE_BYTE,
PIPE_UNLIMITED_INSTANCES, # max instances
0, 0, 6000,
self.CreatePipeSecurityObject())
try:
hr = ConnectNamedPipe(pipeHandle, self.overlapped)
except error, details:
print "Error connecting pipe!", details
CloseHandle(pipeHandle)
break
if hr==winerror.ERROR_PIPE_CONNECTED:
# Client is already connected - signal event
SetEvent(self.overlapped.hEvent)
rc = WaitForMultipleObjects((self.hWaitStop, self.overlapped.hEvent), 0, INFINITE)
if rc==WAIT_OBJECT_0:
# Stop event
break
else:
# Pipe event - spawn thread to deal with it.
thread.start_new_thread(self.ProcessClient, (pipeHandle,))
num_connections = num_connections + 1
# Sleep to ensure that any new threads are in the list, and then
# wait for all current threads to finish.
# What is a better way?
示例4: SvcDoRun
# 需要导入模块: import servicemanager [as 别名]
# 或者: from servicemanager import LogMsg [as 别名]
def SvcDoRun(self):
# do nothing at all - just wait to be stopped
win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE)
# Write a stop message.
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STOPPED,
(self._svc_name_, '')
)
示例5: SvcDoRun
# 需要导入模块: import servicemanager [as 别名]
# 或者: from servicemanager import LogMsg [as 别名]
def SvcDoRun(self):
'''
Called when the service is asked to start
'''
self.start()
servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_, ''))
self.main()
示例6: SvcDoRun
# 需要导入模块: import servicemanager [as 别名]
# 或者: from servicemanager import LogMsg [as 别名]
def SvcDoRun(self):
servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_, ''))
servicemanager.LogInfoMsg('ceajenkins before main')
try:
self.main()
except:
servicemanager.LogErrorMsg(traceback.format_exc())
sys.exit(-1)
servicemanager.LogInfoMsg('normal exit')
示例7: SvcDoRun
# 需要导入模块: import servicemanager [as 别名]
# 或者: from servicemanager import LogMsg [as 别名]
def SvcDoRun(self):
try:
LOG('SvcDoRun')
import servicemanager
servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, ''))
servicemanager.LogInfoMsg("OpsBro Start")
# Set as english
locale.setlocale(locale.LC_ALL, 'English_Australia.1252')
# under service, stdout and stderr are not available
# TODO: enable debug mode?
self.destroy_stdout_stderr()
LOG('BEFORE CLI')
# simulate CLI startup with config parsing
from opsbro.log import cprint, logger, is_tty
from opsbro.cli import CLICommander, save_current_binary
from opsbro.yamlmgr import yamler
with open('c:\\opsbro\\etc\\agent.yml', 'r') as f:
buf = f.read()
CONFIG = yamler.loads(buf)
LOG('CONF LOADED')
# Load config
CLI = CLICommander(CONFIG, None)
LOG('CLI LOADED')
l = Launcher(cfg_dir='c:\\opsbro\\etc')
LOG('LAUNCHER created, launching init & main')
# Note: before launch the start/main, we need to start a stopper thread (on the main process)
l.do_daemon_init_and_start(is_daemon=False, before_start_callback=self._before_start_callback)
LOG('LAUNCHER init')
# called when we're being shut down
except Exception:
err = traceback.format_exc()
LOG('CRASH: %s' % err)
logger_crash.error(err)
raise
示例8: SvcDoRun
# 需要导入模块: import servicemanager [as 别名]
# 或者: from servicemanager import LogMsg [as 别名]
def SvcDoRun(self):
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_, '')
)
self.main()