python启动elasticsearch

import os
import time
import random

elasticsearch = r'C:\elasticsearch-6.5.4\bin\elasticsearch.bat'
kibana = r'C:\elasticsearch-6.5.4\kibana-6.5.4-windows-x86_64\bin\kibana.bat'
def progress_bar(item):
    for i in range(11, 0, -1):
        if item == 'kibana':
            time.sleep(random.random() + 0.8)
        else:
            time.sleep(random.random() + 0.4)
        res = '\r%s正在加载:%s %s%%\n' % (item, ('████' * (12 - i)), (11 - i) * 10) if i == 1 else '\r%s正在加载:%s %s%%' % (
        item,
        (
            '████' * (
            12 - i)),
        (11 - i) * 10)
        print('\033[31m%s\033[0m' % res, end='')


def run():
    for item in [(elasticsearch, 'elasticsearch'), (kibana, 'kibana')]:
        os.system('start %s' % item[0])
        progress_bar(item[1])
        time.sleep(10)


if __name__ == '__main__':
    run()

 

可通过pip install pyinstaller

pyinstaller  -F     run.py     文件名进行打包生成即可

 

 

posted @ 2019-04-28 21:39  小萍瓶盖儿  阅读(124)  评论(0编辑  收藏  举报