From 4cb426cb3ae31e772a09d4ade5b2f0242aaeefa0 Mon Sep 17 00:00:00 2001
From: hyb <kk_huangyangbo@163.com>
Date: Fri, 09 Jan 2026 08:34:47 +0000
Subject: [PATCH] 更新昆明理工压测脚本自动获取token

---
 测试组/脚本/造数脚本2/昆明理工大学/病毒检测.py |   30 +++++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 7 deletions(-)

diff --git "a/\346\265\213\350\257\225\347\273\204/\350\204\232\346\234\254/\351\200\240\346\225\260\350\204\232\346\234\2542/\346\230\206\346\230\216\347\220\206\345\267\245\345\244\247\345\255\246/\347\227\205\346\257\222\346\243\200\346\265\213.py" "b/\346\265\213\350\257\225\347\273\204/\350\204\232\346\234\254/\351\200\240\346\225\260\350\204\232\346\234\2542/\346\230\206\346\230\216\347\220\206\345\267\245\345\244\247\345\255\246/\347\227\205\346\257\222\346\243\200\346\265\213.py"
index cad5ca1..3ef479a 100644
--- "a/\346\265\213\350\257\225\347\273\204/\350\204\232\346\234\254/\351\200\240\346\225\260\350\204\232\346\234\2542/\346\230\206\346\230\216\347\220\206\345\267\245\345\244\247\345\255\246/\347\227\205\346\257\222\346\243\200\346\265\213.py"
+++ "b/\346\265\213\350\257\225\347\273\204/\350\204\232\346\234\254/\351\200\240\346\225\260\350\204\232\346\234\2542/\346\230\206\346\230\216\347\220\206\345\267\245\345\244\247\345\255\246/\347\227\205\346\257\222\346\243\200\346\265\213.py"
@@ -10,26 +10,42 @@
 """
 import sys
 import os
-# 将上一级目录加入模块搜索路径
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 import asyncio
 import aiohttp
 import time
 import traceback
 import datetime
 from tqdm import tqdm
-from Util.random_util import RandomUtil
-from Util.dingtalk_helper import DingTalkHelper
+
+def get_parent_directory(file_path, levels=1):
+  """获取指定层级的父目录"""
+  path = os.path.abspath(file_path)
+  for _ in range(levels):
+    path = os.path.dirname(path)
+  return path
+
+parent_dir = get_parent_directory(__file__, 5)  # 获取上五级目录
+sys.path.append(parent_dir)
+from 测试组.脚本.造数脚本2.Util import TokenValidator, DingTalkHelper, RandomUtil, RequestRecord, LoadTestReportGenerator
 
 
 # --- 配置 ---
 ACCESS_TOKEN = '4625f6690acd9347fae5b3a05af598be63e73d604b933a9b3902425b8f136d4d'
 SECRET = 'SEC3b6937550bd297b5491855f6f40c2ff1b41bc8c495e118ba9848742b1ddf8f19'
 
+# 账号密码配置
+username = "gly"
+password = "Baoyi@1341"
+# 创建获取token实例
+token_validator = TokenValidator()
+
+domain = "http://192.168.6.168:5534"
+token = token_validator.get_token(domain, username, password)
+
 apiname = "病毒检测"
-url = "http://192.168.6.168:5534/api/detection/virusdetection/virusDetection/save"
+url = f"{domain}/api/detection/virusdetection/virusDetection/save"
 headers = {
-    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NjA2Nzk1MDksInVzZXJuYW1lIjoiZ2x5In0.aApZ-cXC_pIw6gdPZHg3TlsgZIaCPRrmlMDM3-zEhtg",
+    "token": token,
     "Content-Type": "application/json"
 }
 
@@ -158,7 +174,7 @@
     try:
         import importlib.util
         script_dir = os.path.dirname(os.path.abspath(__file__))
-        report_path = os.path.join(script_dir, 'H:\\项目\\造数脚本\\Util\\stress_test_report_generator.py')
+        report_path = os.path.join(script_dir, 'H:\\项目\\archive\\测试组\\脚本\\造数脚本2\\Util\\stress_test_report_generator.py')
         if os.path.exists(report_path):
             spec = importlib.util.spec_from_file_location('report_module', report_path)
             report_module = importlib.util.module_from_spec(spec)

--
Gitblit v1.9.1