From 9683aeeafa2f1067ef061b34124a1c362df07e5e Mon Sep 17 00:00:00 2001
From: zhaoqingang <zhaoqg0118@163.com>
Date: 星期四, 03 四月 2025 14:10:13 +0800
Subject: [PATCH] rg配置修改

---
 app/utils/common.py |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/app/utils/common.py b/app/utils/common.py
new file mode 100644
index 0000000..cacda03
--- /dev/null
+++ b/app/utils/common.py
@@ -0,0 +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