'''
代码描述：读取 conf_*.ini 配置文件, 获取路径
'''
import os
import sys
from po.models.doconfIni import DoConfIni

# 获取当前路径
# currentPath
currPath = os.path.split(os.path.realpath(__file__))[0]
# currPath = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# 定义
readConfig = DoConfIni()
config_name = sys.argv[1]

# 使用浏览器
# browser = readConfig.getConfValue(os.path.join(currPath, config_name), 'project', 'browser')

# 读配置文件获取项目路径
proPath = readConfig.getConfValue(os.path.join(currPath, config_name), 'project', 'project_path')

# 登录地址的路径
loginPath = readConfig.getConfValue(os.path.join(currPath, config_name), 'login', 'login_path')

# 数据库配置信息。
pg_host = readConfig.getConfValue(os.path.join(currPath, config_name), 'pgsql', 'host')
pg_port = readConfig.getConfValue(os.path.join(currPath, config_name), 'pgsql', 'port')
pg_user = readConfig.getConfValue(os.path.join(currPath, config_name), 'pgsql', 'user')
pg_password = readConfig.getConfValue(os.path.join(currPath, config_name), 'pgsql', 'password')
pg_database = readConfig.getConfValue(os.path.join(currPath, config_name), 'pgsql', 'database')

# 测试用例路径 (用于准确打开对应项目)
tc_name = readConfig.getConfValue(os.path.join(currPath, config_name), 'project_report', 'project_report')
tcPath = os.path.join(proPath, 'po', 'test_case', tc_name)

# 获取日志路径
logPath = os.path.join(proPath, 'po', 'report', 'Log')

# 获取报告路径
reportPath = os.path.join(proPath, 'po', 'report', 'testreport')

# 获取测试数据路径
dataPath = os.path.join(proPath, 'po', 'data', 'testdata')

# 保存截图路径
# 错误截图
failImagePath = os.path.join(proPath, 'po', 'report', 'image', 'fail')
# 成功截图
passImagePath = os.path.join(proPath, 'po', 'report', 'image', 'pass')

# excl文件名
data_name = readConfig.getConfValue(os.path.join(currPath, config_name), 'data_name', 'data_name')

# socket_io 连接的地址。
socket_io_address = readConfig.getConfValue(os.path.join(currPath, config_name), 'socket_io', 'address')

# 被调函数名称
funcName = '>>> %s', sys._getframe().f_code.co_name
# 被调函数所在行号
funcNo = '>>> %s', sys._getframe().f_back.f_lineno
# 被调函数所在文件名称
funcFile = '>>> %s', sys._getframe().f_code.co_filename

