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

39 lines
940 B
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

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