[fix] use wmic replace uuid.getnode, because of mac address is not stable
This commit is contained in:
parent
a4885e5602
commit
0401c3f57b
@ -373,10 +373,17 @@ def get_mac_address():
|
||||
获取MAC地址
|
||||
"""
|
||||
try:
|
||||
# 获取本机的MAC地址
|
||||
mac = uuid.getnode()
|
||||
mac_str = ':'.join(("%012X" % mac)[i:i+2] for i in range(0, 12, 2))
|
||||
return mac_str
|
||||
result = subprocess.check_output(
|
||||
'wmic nic where "PhysicalAdapter=True" get MACAddress',
|
||||
shell=True,
|
||||
stderr=subprocess.STDOUT,
|
||||
text=True
|
||||
)
|
||||
lines = result.strip().split('\n')
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if line and line != 'MACAddress' and ':' in line:
|
||||
return line
|
||||
except Exception as e:
|
||||
logging.error(f"获取MAC地址失败: {e}")
|
||||
return "00:00:00:00:00:00"
|
||||
|
||||
@ -906,10 +906,17 @@ def get_mac_address():
|
||||
获取MAC地址
|
||||
"""
|
||||
try:
|
||||
# 获取本机的MAC地址
|
||||
mac = uuid.getnode()
|
||||
mac_str = ':'.join(("%012X" % mac)[i:i+2] for i in range(0, 12, 2))
|
||||
return mac_str
|
||||
result = subprocess.check_output(
|
||||
'wmic nic where "PhysicalAdapter=True" get MACAddress',
|
||||
shell=True,
|
||||
stderr=subprocess.STDOUT,
|
||||
text=True
|
||||
)
|
||||
lines = result.strip().split('\n')
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if line and line != 'MACAddress' and ':' in line:
|
||||
return line
|
||||
except Exception as e:
|
||||
logging.error(f"获取MAC地址失败: {e}")
|
||||
return "00:00:00:00:00:00"
|
||||
|
||||
@ -56,10 +56,17 @@ def get_mac_address():
|
||||
获取MAC地址
|
||||
"""
|
||||
try:
|
||||
# 获取本机的MAC地址
|
||||
mac = uuid.getnode()
|
||||
mac_str = ':'.join(("%012X" % mac)[i:i+2] for i in range(0, 12, 2))
|
||||
return mac_str
|
||||
result = subprocess.check_output(
|
||||
'wmic nic where "PhysicalAdapter=True" get MACAddress',
|
||||
shell=True,
|
||||
stderr=subprocess.STDOUT,
|
||||
text=True
|
||||
)
|
||||
lines = result.strip().split('\n')
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if line and line != 'MACAddress' and ':' in line:
|
||||
return line
|
||||
except Exception as e:
|
||||
logging.error(f"获取MAC地址失败: {e}")
|
||||
return "00:00:00:00:00:00"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user