113 lines
3.3 KiB
Python
113 lines
3.3 KiB
Python
import os
|
|
import threading
|
|
from compareData import Comparator
|
|
from getDataFromAS import ASDataFetcher
|
|
from getQueries import getQueries_From_json
|
|
import config
|
|
|
|
# 拼接导出页面查询json文件夹路径
|
|
json_folder_path = os.path.join(config.CURRENT_DIR_PATH, "Export_Json")
|
|
# 拼接查询结果excel文件夹路径
|
|
result_folder_path = os.path.join(config.CURRENT_DIR_PATH, "Evaluate_Result")
|
|
# 检查文件夹是否存在,如果不存在则创建它
|
|
if not os.path.exists(json_folder_path):
|
|
os.makedirs(json_folder_path)
|
|
if not os.path.exists(result_folder_path):
|
|
os.makedirs(result_folder_path)
|
|
|
|
# 拼接导出页面查询json文件路径
|
|
export_page_json_path_1 = os.path.join(json_folder_path, config.EXPORT_PAGE_JSON_NAME_1)
|
|
export_page_json_path_2 = os.path.join(json_folder_path, config.EXPORT_PAGE_JSON_NAME_2)
|
|
# 读取json文件中的查询
|
|
queries_1 = getQueries_From_json(export_page_json_path_1)
|
|
queries_2 = getQueries_From_json(export_page_json_path_2)
|
|
|
|
# 创建 ASDataFetcher 实例
|
|
fetcher_1 = ASDataFetcher(
|
|
workspace=config.WORKSPACE_1,
|
|
username=config.USERNAME_1,
|
|
password=config.PASSWORD_1,
|
|
queries=queries_1,
|
|
json_name=config.EXPORT_PAGE_JSON_NAME_1,
|
|
result_folder_path=result_folder_path,
|
|
isAdmin=config.IS_ADMIN_1,
|
|
catalog=config.CATALOG_1,
|
|
effective_username=config.EFFECTIVE_USERNAME_1,
|
|
customdata=config.CUSTOMER_DATA_1,
|
|
role=config.ROLE_1,
|
|
model_number=1,
|
|
)
|
|
|
|
# 创建 ASDataFetcher 实例
|
|
fetcher_2 = ASDataFetcher(
|
|
workspace=config.WORKSPACE_2,
|
|
username=config.USERNAME_2,
|
|
password=config.PASSWORD_2,
|
|
queries=queries_2,
|
|
json_name=config.EXPORT_PAGE_JSON_NAME_2,
|
|
result_folder_path=result_folder_path,
|
|
isAdmin=config.IS_ADMIN_2,
|
|
catalog=config.CATALOG_2,
|
|
effective_username=config.EFFECTIVE_USERNAME_2,
|
|
customdata=config.CUSTOMER_DATA_2,
|
|
role=config.ROLE_2,
|
|
model_number=2,
|
|
)
|
|
|
|
# 定义线程任务
|
|
def run_fetcher(fetcher, print_lock):
|
|
fetcher.writeToExcel(print_lock)
|
|
|
|
# 创建锁
|
|
print_lock = threading.Lock()
|
|
|
|
# 创建线程
|
|
thread_1 = threading.Thread(target=run_fetcher, args=(fetcher_1, print_lock))
|
|
thread_2 = threading.Thread(target=run_fetcher, args=(fetcher_2, print_lock))
|
|
|
|
try:
|
|
print(
|
|
f"""
|
|
---*********************************************************---
|
|
开始查询
|
|
"""
|
|
)
|
|
# 启动线程
|
|
thread_1.start()
|
|
thread_2.start()
|
|
|
|
# 等待线程完成
|
|
thread_1.join()
|
|
thread_2.join()
|
|
|
|
print(
|
|
f"""
|
|
查询完成
|
|
---*********************************************************---
|
|
"""
|
|
)
|
|
except Exception as e:
|
|
print(f"错误提示: {e}")
|
|
|
|
try:
|
|
print(
|
|
"""
|
|
---------------------------------------------------------------
|
|
开始比较
|
|
---------------------------------------------------------------
|
|
"""
|
|
)
|
|
comparator = Comparator(
|
|
fetcher_1.result_full_excel_name, fetcher_2.result_full_excel_name
|
|
)
|
|
comparator.compare_ExcelFiles()
|
|
print(
|
|
"""
|
|
----------------------------------------------------------------
|
|
比较完成
|
|
----------------------------------------------------------------
|
|
"""
|
|
)
|
|
except Exception as e:
|
|
print(f"错误提示: {e}")
|