pyInstallZabbixAgentWin.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:LinuxBashShellScriptForOps 作者: DingGuodong 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号