🤖 自动格式化代码 [skip ci]

This commit is contained in:
github-actions[bot]
2025-05-06 13:02:29 +00:00
parent adb943cac3
commit ca55d646e1

View File

@@ -6,6 +6,7 @@ import os
import json import json
import threading import threading
import subprocess import subprocess
# from loguru import logger # from loguru import logger
from src.common.logger_manager import get_logger from src.common.logger_manager import get_logger
from src.config.config import global_config from src.config.config import global_config
@@ -81,6 +82,7 @@ def get_unique_id():
def generate_unique_id(): def generate_unique_id():
# 基于机器码生成唯一ID同一台机器上生成的UUID是固定的只要机器码不变 # 基于机器码生成唯一ID同一台机器上生成的UUID是固定的只要机器码不变
import hashlib import hashlib
system_info = platform.system() system_info = platform.system()
machine_code = None machine_code = None
@@ -88,7 +90,7 @@ def generate_unique_id():
if system_info == "Windows": if system_info == "Windows":
# 使用wmic命令获取主机UUID更稳定 # 使用wmic命令获取主机UUID更稳定
result = subprocess.check_output( result = subprocess.check_output(
'wmic csproduct get uuid', shell=True, stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL "wmic csproduct get uuid", shell=True, stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL
) )
lines = result.decode(errors="ignore").splitlines() lines = result.decode(errors="ignore").splitlines()
# 过滤掉空行和表头只取有效UUID # 过滤掉空行和表头只取有效UUID
@@ -117,6 +119,7 @@ def generate_unique_id():
uuid_line = result.decode(errors="ignore") uuid_line = result.decode(errors="ignore")
# 解析出 "IOPlatformUUID" = "xxxx-xxxx-xxxx-xxxx" # 解析出 "IOPlatformUUID" = "xxxx-xxxx-xxxx-xxxx"
import re import re
m = re.search(r'"IOPlatformUUID"\s*=\s*"([^"]+)"', uuid_line) m = re.search(r'"IOPlatformUUID"\s*=\s*"([^"]+)"', uuid_line)
if m: if m:
uuid_val = m.group(1) uuid_val = m.group(1)
@@ -238,6 +241,7 @@ def main():
return heartbeat_thread # 返回线程对象,便于外部控制 return heartbeat_thread # 返回线程对象,便于外部控制
return None return None
# --- 测试用例 --- # --- 测试用例 ---
if __name__ == "__main__": if __name__ == "__main__":
print("测试唯一ID生成") print("测试唯一ID生成")