AI实验室后端
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import asyncio
|
||||
import platform
|
||||
import socket
|
||||
import threading
|
||||
from datetime import datetime
|
||||
|
||||
import psutil
|
||||
import pytz
|
||||
|
||||
|
||||
@@ -65,3 +68,35 @@ def is_valid_uuid(value: str):
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
def get_local_ip():
|
||||
try:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
s.connect(("8.8.8.8", 80))
|
||||
ip = s.getsockname()[0]
|
||||
s.close()
|
||||
return ip
|
||||
except Exception:
|
||||
return "127.0.0.1"
|
||||
|
||||
|
||||
def get_mac_address():
|
||||
# 获取第一个网卡的 MAC
|
||||
for iface, addrs in psutil.net_if_addrs().items():
|
||||
for addr in addrs:
|
||||
if addr.family == psutil.AF_LINK:
|
||||
return addr.address
|
||||
return "00:00:00:00:00:00"
|
||||
|
||||
|
||||
def get_cpu_info():
|
||||
return platform.processor()
|
||||
|
||||
|
||||
def get_memory_total():
|
||||
return psutil.virtual_memory().total
|
||||
|
||||
|
||||
def get_disk_total():
|
||||
return psutil.disk_usage("/").total
|
||||
|
||||
Reference in New Issue
Block a user