script/Testlink转换工具/ExcelToXml2/check.py

33 lines
732 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- encoding: utf-8 -*-
import os
import sys
# 用于环境检查
# 检查Python版本
# 检查Python模块需要xlrd
def check_env():
# 检查input文件夹
input_dir = os.path.join(os.getcwd(), 'input')
if not os.path.exists(input_dir):
os.mkdir(input_dir)
# 检查xlrd模块
try:
import xlrd
except:
print(u'缺少xlrd模块将自动安装...')
# 执行安装
p = os.popen('pip install xlrd')
print(p.read())
import xlrd
finally:
print('***************************')
print(u'环境配置正常,可以运行转换工具')
print('***************************')
if __name__ == "__main__":
check_env()