From 947cf0d625accd92edf1a5a832b12c2debddfd38 Mon Sep 17 00:00:00 2001
From: zhaoqingang <zhaoqg0118@163.com>
Date: 星期五, 09 五月 2025 14:39:23 +0800
Subject: [PATCH] 配置参数优化
---
app/utils/common.py | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/app/utils/common.py b/app/utils/common.py
index e3ac4a6..cacda03 100644
--- a/app/utils/common.py
+++ b/app/utils/common.py
@@ -1,6 +1,31 @@
import pytz
+import platform
+import subprocess
+
from datetime import datetime
+
def current_time():
tz = pytz.timezone('Asia/Shanghai')
return datetime.now(tz)
+
+
+def get_machine_id():
+ """鑾峰彇鏈哄櫒鐨勫敮涓�鏍囪瘑"""
+ if platform.system() == "Windows":
+ # Windows 绯荤粺
+ command = "wmic csproduct get UUID"
+ process = subprocess.Popen(command.split(), stdout=subprocess.PIPE)
+ output, _ = process.communicate()
+ machine_id = output.decode().strip().split("\n")[1].strip()
+ elif platform.system() == "Darwin":
+ # macOS 绯荤粺
+ command = "system_profiler SPHardwareDataType | grep 'Hardware UUID' | awk '{print $4}'"
+ process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
+ output, _ = process.communicate()
+ machine_id = output.decode().strip()
+ else:
+ # Linux 绯荤粺
+ machine_id = open("/etc/machine-id").read().strip()
+ # print(machine_id)
+ return machine_id
\ No newline at end of file
--
Gitblit v1.8.0