def install_service():
import win32api
import time
if not os.path.exists(zabbix_install_log):
log.info('Install zabbix service')
try:
win32api.ShellExecute(0, 'runas', zabbix_agent_bin_file,
'--config %s --install' % zabbix_agent_conf_file, '', 0)
time.sleep(2) # it is not essential
log.info('Install zabbix service finished')
with open(zabbix_install_log, 'w') as f:
f.write(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) + ' service installed.')
except Exception as e:
print e
for item in list(e):
if isinstance(item, str):
print item.decode(DEFAULT_LOCALE_ENCODING),
else:
print item,
log.error('Install zabbix service failed')
raise RuntimeError
pyInstallZabbixAgentWin.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录